使用自定义模板创建脚本

编程入门 行业动态 更新时间:2024-10-28 18:22:44
本文介绍了使用自定义模板创建脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要将以下内容作为Unity编辑器中添加的新C#脚本的默认模板.

I need to make the following as the default template of my new C# scripts added in Unity Editor.

using System.Collections; using System.Collections.Generic; using UnityEngine; namespace ProjectName { public class ScriptName: MonoBehaviour { /// <summary> /// /// </summary> #region Fields #endregion #region MonoBehaviour Messages void Start() { } void Update() { } #endregion #region Methods #endregion } }

ProjectName是所有脚本的常量,而ScriptName是在脚本资产创建时定义的.

The ProjectName is a constant for all scripts, while ScriptName is defined on script asset creation.

我尝试使用UnityEditor文档,并检查了以下问题" Unity将默认命名空间添加到脚本模板?",但无法实现上述模板

I tried using UnityEditor documentation and checked this question "Unity Add Default Namespace to Script Template?" but couldn't implement the above template

推荐答案

我检查了一下,但是没有问题.

I checked that but there's no problem.

检查此点

  • 项目中Assets/Editor中的AddNameSpace类是吗?

  • Is AddNameSpace class in the Assets/Editor in project?

    如果您开发CS,请在Unity \ Editor \ Data \ Resources \ ScriptTemplates

    If you develop CS, modify 81-C# Script-NewBehaviourScript.cs in Unity\Editor\Data\Resources\ScriptTemplates

  • 更多推荐

    使用自定义模板创建脚本

    本文发布于:2023-11-16 04:44:47,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1601105.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:自定义   脚本   模板

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!