zoukankan      html  css  js  c++  java
  • CocosCreator 自定义脚本

    版本:3.3.1

    参考: cocos文档-脚本创建

    一  复制引擎路径下的ts模板文件

    C:CocosDashboard_1.0.12 esources.editorsCreator3.3.1 esources esources3dengineeditorassetsdefault_file_content s

    ts:

    import { _decorator, Component, Node } from 'cc';
    const { ccclass, property } = _decorator;
    
    /**
     * Predefined variables
     * Name = <%Name%>
     * DateTime = <%DateTime%>
     * Author = <%Author%>
     * FileBasename = <%FileBasename%>
     * FileBasenameNoExtension = <%FileBasenameNoExtension%>
     * URL = <%URL%>
     * ManualUrl = <%ManualUrl%>
     *
     */
     
    @ccclass('<%Name%>')
    export class <%Name%> extends Component {
        // [1]
        // dummy = '';
    
        // [2]
        // @property
        // serializableDummy = 0;
    
        start () {
            // [3]
        }
    
        // update (deltaTime: number) {
        //     // [4]
        // }
    }
    
    /**
     * [1] Class member could be defined like this.
     * [2] Use `property` decorator if your want the member to be serializable.
     * [3] Your initialization goes here.
     * [4] Your update function goes here.
     *
     * Learn more about scripting: <%ManualUrl%>scripting/
     * Learn more about CCClass: <%ManualUrl%>scripting/ccclass.html
     * Learn more about life-cycle callbacks: <%ManualUrl%>scripting/life-cycle-callbacks.html
     */
    

      

    二 粘贴修改ts文件

    粘贴ts到.creatorasset-template ypescript (没有则新建文件夹)

    修改复制粘贴的ts文件名为NewTS,内容修改如下:

    import { _decorator, Component, Node } from 'cc';
    const { ccclass, property } = _decorator;
    
    /**
     * @author chenkai <%DateTime%>
     */
    @ccclass('<%Name%>')
    export class <%Name%> extends Component {
    
        onLoad () {
            
        }
    	
    	start(){
    	
    	}
    	
    	onDestroy(){
    		
    	}
    }
    

      

    三 使用新建的模板

    在cocos新建typescript,选择刚刚粘贴修改的NewTS

    新建的模板typescript如下

  • 相关阅读:
    NOI-1.1-04输出保留3位小数的浮点数
    百练7619-合影效果-2015正式D题-简单排序&输出格式
    百练6376-二维数组右上左下遍历-2015正式C题
    C++ 开发环境配置
    go语言 http学习
    Git 命令及分支管理学习
    配置go语言编辑环境
    DNS的过程
    Split Array into Consecutive Subsequences
    组委会正在为美团点评CodeM大赛的决赛设计新赛制
  • 原文地址:https://www.cnblogs.com/gamedaybyday/p/15351395.html
Copyright © 2011-2022 走看看