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"))
    //        {
    
    //        }
    //    }
    //}
  • 相关阅读:
    c语言练习24——数列求和
    Excel 常用属性的一小部分
    常见问题一之拼接表格 js传递参数变量 Json接收值
    关于下拉列表HtmlDownlistFor的使用
    Quay 基础版安装和部署
    Prometheus使用blackbox_exporter监控端口及网站状态(七)
    在CentOS 8上安装PostgreSQL 13 | RHEL 8
    nfs配置以及No route to host解决
    LNMP分离安装
    Linux配置和管理设备映射多路径multipath
  • 原文地址:https://www.cnblogs.com/123ing/p/3767570.html
Copyright © 2011-2022 走看看