• MyTools


    using UnityEditor;
    using UnityEngine;
    using System.IO;
    using System.Collections;
    using System.Collections.Generic;
    
    public class MyTools
    {
        [MenuItem("MyTools/RenameSelected")]
        static void RenameSelected()
        {
            Transform[] trans = Selection.GetTransforms(SelectionMode.Assets);
    
            if (trans.Length > 0)
            {
                foreach (Transform item in trans)
                {
                    string tempName = item.gameObject.name;
    
                    string[] ary = tempName.Split(new char[] { '(', ')' }, System.StringSplitOptions.RemoveEmptyEntries);
    
                    tempName = ary[1] + " " + ary[0];
    
                    item.name = tempName;
                }
            }
            else
            {
                Debug.Log("请选择父对象");
            }
        }
    
        [MenuItem("MyTools/AddEmptyToSelected")]
        static void AddEmptyToSelected()
        {
            Transform[] trans = Selection.GetTransforms(SelectionMode.Assets);
            if (trans.Length > 0)
            {
                GameObject go = new GameObject();
                go.name = "GameObject";
                go.transform.parent = trans[0];
                go.transform.localPosition = Vector3.zero;
                go.transform.localRotation = Quaternion.Euler(Vector3.zero);
                go.transform.localScale = new Vector3(1, 1, 1);
            }
            else
            {
                Debug.Log("请选择父对象");
            }
    
            // AssetDatabase.CreateFolder("Assets","ZJW");
            // Undo.PerformRedo();
    
            //Undo.PerformUndo();
    
    
            //foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
            //{
            //    Debug.Log(o.name);
            //    //    if (!(o is object))
            //    //continue;
    
            //    //assetdatabase.renameasset(assetdatabase.getassetpath(o), "1" + o.name);
            //}
    
            // if (Selection.objects.Length <= 0)
            // {
            // Debug.Log("gos[0].name");
            // }
            // else
            // {
            // foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
            // {
            // if (!(o is Object))
            // continue;
            // AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(o), "1" + o.name);
            // }
            // }
        }
    
        [MenuItem("MyTools/CreateFullDirectory")]
        static void CreateFullDirectory()
        {
            if (!Directory.Exists(Application.dataPath + "/Scripts"))
            {
                AssetDatabase.CreateFolder("Assets", "Scripts");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Documents"))
            {
                AssetDatabase.CreateFolder("Assets", "Documents");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Scenes"))
            {
                AssetDatabase.CreateFolder("Assets", "Scenes");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Plugins"))
            {
                AssetDatabase.CreateFolder("Assets", "Plugins");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Models"))
            {
                AssetDatabase.CreateFolder("Assets", "Models");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Materials"))
            {
                AssetDatabase.CreateFolder("Assets", "Materials");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Animations"))
            {
                AssetDatabase.CreateFolder("Assets", "Animations");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Audios"))
            {
                AssetDatabase.CreateFolder("Assets", "Audios");
    
                if (!Directory.Exists(Application.dataPath + "/Audios/Sounds"))
                {
                    Directory.CreateDirectory(Application.dataPath + "/Audios/Sounds");
                }
    
                if (!Directory.Exists(Application.dataPath + "/Audios/Musics"))
                {
                    Directory.CreateDirectory(Application.dataPath + "/Audios/Musics");
                }
            }
    
            if (!Directory.Exists(Application.dataPath + "/Atals"))
            {
                AssetDatabase.CreateFolder("Assets", "Atals");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Fonts"))
            {
                AssetDatabase.CreateFolder("Assets", "Fonts");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Prefabs"))
            {
                AssetDatabase.CreateFolder("Assets", "Prefabs");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Shaders"))
            {
                AssetDatabase.CreateFolder("Assets", "Shaders");
            }
    
            if (!Directory.Exists(Application.dataPath + "/StreamingAssets"))
            {
                AssetDatabase.CreateFolder("Assets", "StreamingAssets");
            }
    
            if (!Directory.Exists(Application.dataPath + "/Effects"))
            {
                AssetDatabase.CreateFolder("Assets", "Effects");
            }
        }
    }
    
    //public class TestWindow : EditorWindow 
    //{
    //    string[] inspectToolbarStrings = { "Textures", "Materials", "Meshes" };
    //    enum InspectType
    //    {
    //        Textures, Materials, Meshes
    //    };
    
    //    InspectType ActiveInspectType = InspectType.Textures;
    
    //    [MenuItem("MyTools/TestWindow")]
    //    static void Init()
    //    {
    //        TestWindow window = (TestWindow)EditorWindow.GetWindow(typeof(TestWindow));
    //        window.minSize = new Vector2(100, 300);
    //    }
    //    void OnGUI()
    //    {
    //        bool b = false;
    //        if (b =GUILayout.Toggle(true, "123"))
    //        {
    //            b = true;
    //        }
    
    //        string str= GUILayout.TextArea("");
    
    //        if (GUILayout.Button("Meshes"))
    //        {
    //            Debug.Log(str);
    //        }
    
    //        if (GUILayout.Button("Textures"))
    //        {
    
    //        }
    
    //        if (GUILayout.Button("Materials"))
    //        {
    
    //        }
    //    }
    //}
  • 相关阅读:
    小总结:fibonacci数的产生
    pick the stone game
    温故知新的错题训练:Coin game
    《博弈论的诡计》
    思维+博弈论:字符串操作
    一下午的编程思索录
    2018中国大学生程序设计竞赛
    温故知新的经典贪心题目:今年暑假不AC?
    2019-2020新学的一些东西(持续更新)
    【半平面交】JZOJ3297. 【SDOI2013】逃考
  • 原文地址:https://www.cnblogs.com/123ing/p/3767570.html
Copyright © 2020-2023  润新知