码迷,mamicode.com
首页 > 其他好文 > 详细

MyTools

时间:2014-06-06 07:42:32      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

bubuko.com,布布扣
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"))
//        {

//        }
//    }
//}
bubuko.com,布布扣

 

MyTools,布布扣,bubuko.com

MyTools

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/123ing/p/3767570.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!