首页 > 代码库 > MyTools
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")) // { // } // } //}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。