예제 #1
0
 static void BuildSprite(Object asset)
 {
     AssetDatabase.Refresh();
     if (asset is SimpleSpritePacker.SPInstance)
     {
         AssetToolsEditor.BuildAsset(asset, "sp", "Assets/StreamingAssets/res/ui/sprite");
     }
 }
예제 #2
0
 private static void BuildUITex()
 {
     foreach (Object asset in Selection.objects)
     {
         AssetDatabase.Refresh();
         if (asset is Texture)
         {
             AssetToolsEditor.BuildAsset(asset, "tex", "Assets/StreamingAssets/res/ui/tex");
         }
     }
 }
예제 #3
0
    static void BuildUI(bool child)
    {
        UnityEngine.Object[] objects = Selection.objects;
        foreach (Object asset in objects)
        {
            if (asset is GameObject)
            {
                GameObject UI = asset as GameObject;
                if (child)
                {
                    RepairUGUI(UI);
                }

                Image[] images = UI.GetComponentsInChildren <Image>(true);

                if (images != null && images.Length > 0)
                {
                    for (int i = 0; i < images.Length; i++)
                    {
                        if (images[i] is CImage)
                        {
                            continue;
                        }
                        EditorUtility.DisplayDialog("Error", asset.name + "包含Image,请执行>> UI脚本更换 <<", "OK");
                        return;
                    }
                }

                Text[] textarray = UI.GetComponentsInChildren <Text>(true);
                if (textarray != null && textarray.Length > 0)
                {
                    for (int i = 0; i < textarray.Length; i++)
                    {
                        if (textarray[i] is CText)
                        {
                            continue;
                        }
                        EditorUtility.DisplayDialog("Error", asset.name + "包含Text,请执行>> UI脚本更换 <<", "OK");
                        return;
                    }
                }

                CImage[] sprites = UI.GetComponentsInChildren <CImage>(true);
                for (int j = 0; j < sprites.Length; j++)
                {
                    CImage sprite = sprites[j];
                    if (child)
                    {
                        BuildSprite(sprite.sprite);
                    }
                    sprite.sprite = null;
                }

                CText[] texts = UI.GetComponentsInChildren <CText>(true);
                for (int j = 0; j < texts.Length; j++)
                {
                    texts[j].font = null;
                }
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
                AssetToolsEditor.BuildAsset(asset, "ui", "Assets/StreamingAssets/res/ui/uiprefab");

                RepairUGUI(UI);
            }
        }
        AssetDatabase.Refresh();
    }