zoukankan      html  css  js  c++  java
  • 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"))
    //        {
    
    //        }
    //    }
    //}
  • 相关阅读:
    Error: could not open `C:Program FilesJavajre6libi386jvm.cfg'
    异常:java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/app/userInfoMaint/getProvince.do'
    解析Java反射
    Cause: java.sql.SQLException: 无效的列索引
    Internet Explorer 无法打开该 Internet 站点,请求的站点不可用或无法找到
    解决The JSP specification requires that an attribute name is preceded by whitespace问题
    pl/sql的to_char和to_date
    oracle 在xml中批量插入,批量修改及多组条件查询
    时间转换模板
    Java网络编程从入门到精通(5):使用InetAddress类的getHostName方法获得域名
  • 原文地址:https://www.cnblogs.com/123ing/p/3767570.html
Copyright © 2011-2022 走看看