Esempio n. 1
0
        private static void IgnoreAsmDefFolder()
        {
            string ignorePath = Path.Combine(ProjectBrowserExt.GetSelectedPath(), "ignore.asmdef");

            File.WriteAllText(Path.GetFullPath(ignorePath)
                              , Template.TransformToText <ignore_asmdef>(new Dictionary <string, object>
            {
                { "guid", Guid.NewGuid().ToString() },
#if !NETSTANDARD
                { "platforms", CustomScriptAssemblyEx.Platforms.Select(p => $@"""{p.Name}""") }
#endif
            }));

            AssetDatabase.ImportAsset(ignorePath);
            AssetDatabase.Refresh();
        }
Esempio n. 2
0
        private static void CreateNewCSharpScript()
        {
            string scriptPath   = Path.Combine(ProjectBrowserExt.GetSelectedPath(), "NewBehaviourScript.cs");
            string templatePath = Path.Combine(Path.GetTempPath(), "NewBehaviourScript.cs");

            File.WriteAllText(Path.GetFullPath(templatePath)
                              , Template.TransformToText <DerivedClass_cs>(new Dictionary <string, object>
            {
                { "namespacename", UnityEditorExSettings.instance.GetNamespaceName(scriptPath) },
                { "classname", "#SCRIPTNAME#" },
                { "baseclassname", "MonoBehaviour" },
                { "isPartial", false },
                { "content", "" }
            }));

            ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, scriptPath);
        }
Esempio n. 3
0
        static void CreateAndSetAnimatorController(MenuCommand command)
        {
            Animator animator = command.context as Animator;
            string   path     = ProjectBrowserExt.GetSelectedPath();
            string   name     = Selection.activeObject.name.Replace(" ", "") + "AnimatorController";

            path = Path.Combine(path, name + ".controller");
            AnimatorController animatorController = new AnimatorController();

            animatorController.name = Path.GetFileName(path);
            AssetDatabase.CreateAsset(animatorController, path);
            //animatorController.pushUndo = false;
            animatorController.AddLayer("Base Layer");
            //animatorController.pushUndo = true;
            AssetDatabase.ImportAsset(path);

            animator.runtimeAnimatorController = AssetDatabase.LoadAssetAtPath <RuntimeAnimatorController>(path);
        }
Esempio n. 4
0
        public static void AddGameObjectScript(MenuCommand command)
        {
            Transform transfrom  = command.context as Transform;
            string    scriptPath = Path.Combine(ProjectBrowserExt.GetSelectedPath(), transfrom.gameObject.name + ".cs");

            File.WriteAllText(Path.GetFullPath(scriptPath)
                              , Template.TransformToText <DerivedClass_cs>(new Dictionary <string, object>
            {
                { "namespacename", UnityEditorExSettings.instance.GetNamespaceName(scriptPath) },
                { "classname", transfrom.gameObject.name },
                { "baseclassname", "MonoBehaviour" },
            }));

            AssetDatabase.ImportAsset(scriptPath);
            AssetDatabase.Refresh();

            MonoScript script = AssetDatabase.LoadAssetAtPath <MonoScript>(scriptPath);

            script.SetScriptTypeWasJustCreatedFromComponentMenu();
            InternalEditorUtilityEx.AddScriptComponentUncheckedUndoable(transfrom.gameObject, script);
        }