Пример #1
0
 public static void ShowAllAsset()
 {
     string[] paths = AssetMenu.GetAllAssetPaths("Assets/");
     foreach (string path in paths)
     {
         Debug.Log(path);
     }
 }
Пример #2
0
    private static bool CanCheckTextureFormatManual()
    {
        string path = "";

        if (AssetMenu.CheckSelectionFileDir(ref path))
        {
            return(true);
        }
        return(false);
    }
Пример #3
0
    static bool CanCheck()
    {
        string path = "";

        if (AssetMenu.CheckSelectionFileDir(ref path))
        {
            return(true);
        }
        return(false);
    }
Пример #4
0
    private static void CheckReferenceMissingFunc()
    {
        string path = "";

        string[] prefabPath;
        if (AssetMenu.CheckSelectionFileDir(ref path))
        {
            string[] guids  = AssetDatabase.FindAssets("t:Prefab", new string[] { path });
            string[] guids2 = AssetDatabase.FindAssets("t:Scene", new string[] { path });
            prefabPath = new string[guids.Length + guids2.Length];
            for (int i = 0; i < guids.Length; i++)
            {
                prefabPath[i] = AssetDatabase.GUIDToAssetPath(guids[i]);
            }
            for (int i = 0; i < guids2.Length; i++)
            {
                prefabPath[guids.Length + i] = AssetDatabase.GUIDToAssetPath(guids2[i]);
            }
        }
        else
        {
            prefabPath = new string[Selection.objects.Length];
            for (int i = 0; i < prefabPath.Length; i++)
            {
                prefabPath[i] = AssetDatabase.GetAssetPath(Selection.objects[i]);
            }
        }

        for (int i = 0; i < prefabPath.Length; i++)
        {
            if (!prefabPath[i].EndsWith(".prefab") && !prefabPath[i].EndsWith(".unity"))
            {
                continue;
            }
            Object obj = AssetDatabase.LoadAssetAtPath <Object>(prefabPath[i]);
            EditorUtility.DisplayProgressBar("检测预设-场景空引用", obj.name, (float)(i + 1) / prefabPath.Length);
            if (obj.GetType() == typeof(SceneAsset))
            {
                EditorSceneManager.OpenScene(prefabPath[i]);
                GameObject[] gos = Object.FindObjectsOfType <GameObject>();
                for (int j = 0; j < gos.Length; j++)
                {
                    FindMissingReference(obj.name, gos[j]);
                }
            }
            else
            {
                GameObject go = obj as GameObject;
                FindMissingReference("", go);
            }
        }
        Debug.Log("检测结束");
        EditorUtility.ClearProgressBar();
    }
Пример #5
0
    private static void ReimportAssetByRule()
    {
        string path = "";

        string[] prefabPath;
        if (AssetMenu.CheckSelectionFileDir(ref path))
        {
            string[] guids  = AssetDatabase.FindAssets("t:texture2D", new string[] { path });
            string[] guids2 = AssetDatabase.FindAssets("t:Model", new string[] { path });
            prefabPath = new string[guids.Length + guids2.Length];
            for (int i = 0; i < guids.Length; i++)
            {
                prefabPath[i] = AssetDatabase.GUIDToAssetPath(guids[i]);
            }
            for (int i = 0; i < guids2.Length; i++)
            {
                prefabPath[guids.Length + i] = AssetDatabase.GUIDToAssetPath(guids2[i]);
            }
        }
        else
        {
            prefabPath = new string[Selection.objects.Length];
            for (int i = 0; i < prefabPath.Length; i++)
            {
                prefabPath[i] = AssetDatabase.GetAssetPath(Selection.objects[i]);
            }
        }

        for (int i = 0; i < prefabPath.Length; i++)
        {
            if (!prefabPath[i].EndsWith(".FBX") && !prefabPath[i].EndsWith(".tga") &&
                !prefabPath[i].EndsWith(".png") && !prefabPath[i].EndsWith(".jpg"))
            {
                continue;
            }
            EditorUtility.DisplayProgressBar("按照设置重新导入", prefabPath[i], (float)(i + 1) / prefabPath.Length);
            AssetImporter ai = AssetImporter.GetAtPath(prefabPath[i]);
            if (null != ai)
            {
                ProjectImportSettings.ApplyRulesToObject(ai);
                ai.SaveAndReimport();
            }
        }
        EditorUtility.ClearProgressBar();
    }
Пример #6
0
    private static void CheckTextureFormatManual()
    {
        string dir = "";

        if (!AssetMenu.CheckSelectionFileDir(ref dir))
        {
            return;
        }
        int  totalCount;
        long totalMem;
        List <TextureData> outputs = DoCheckTextureFormat(dir, out totalCount, out totalMem);

        for (int i = 0; i < outputs.Count; i++)
        {
            Debug.Log(outputs[i].Message, outputs[i].Tex);
        }
        outputs.Clear();
    }
Пример #7
0
    private static bool CanCheckReferenceMissingFunc()
    {
        string path = "";

        if (AssetMenu.CheckSelectionFileDir(ref path))
        {
            return(true);
        }
        else
        {
            //选择的物体只要有一个是预设则返回true
            for (int i = 0; i < Selection.objects.Length; i++)
            {
                if (AssetDatabase.GetAssetPath(Selection.objects[i]).EndsWith(".prefab") ||
                    AssetDatabase.GetAssetPath(Selection.objects[i]).EndsWith(".unity"))
                {
                    return(true);
                }
            }
            return(false);
        }
    }
Пример #8
0
    static void DoCheck()
    {
        string path = "";

        if (AssetMenu.CheckSelectionFileDir(ref path))
        {
            string               resultPath    = Application.dataPath + "/../TroopAnimationClip.txt";
            StreamWriter         writer        = new StreamWriter(resultPath);
            List <string>        filesPath     = IGG.FileUtil.GetAllChildFiles(path, ".FBX");
            List <AnimationClip> wait2ClipList = new List <AnimationClip>();
            List <AnimationClip> otherClipList = new List <AnimationClip>();
            for (int i = 0; i < filesPath.Count; i++)
            {
                EditorUtility.DisplayProgressBar("检测小兵动画", filesPath[i], (float)i / filesPath.Count);
                AnimationClip clip = AssetDatabase.LoadAssetAtPath(filesPath[i], typeof(AnimationClip)) as AnimationClip;
                if (null != clip)
                {
                    if (clip.name.ToLower().Contains("wait2"))
                    {
                        if ((int)(clip.frameRate * clip.length) > 60)
                        {
                            wait2ClipList.Add(clip);
                        }
                    }
                    else
                    {
                        if ((int)(clip.frameRate * clip.length) > 30)
                        {
                            otherClipList.Add(clip);
                        }
                    }
                }
            }
            //
            wait2ClipList.Sort((a, b) =>
            {
                return((b.frameRate * b.length).CompareTo(a.frameRate * a.length));
            });
            otherClipList.Sort((a, b) =>
            {
                return((b.frameRate * b.length).CompareTo(a.frameRate * a.length));
            });
            writer.WriteLine("===================wait2动作超过60帧===================");
            for (int i = 0; i < wait2ClipList.Count; i++)
            {
                int    frame    = (int)(wait2ClipList[i].frameRate * wait2ClipList[i].length);
                string clipPath = AssetDatabase.GetAssetPath(wait2ClipList[i]);
                writer.WriteLine(frame + "  " + clipPath);
            }
            writer.WriteLine(" ");
            writer.WriteLine("===================其他动作超过30帧===================");
            for (int i = 0; i < otherClipList.Count; i++)
            {
                int    frame    = (int)(otherClipList[i].frameRate * otherClipList[i].length);
                string clipPath = AssetDatabase.GetAssetPath(otherClipList[i]);
                writer.WriteLine(frame + "  " + clipPath);
            }
            writer.WriteLine("===================检测结束===================");
            EditorUtility.ClearProgressBar();
            writer.Flush();
            writer.Close();
            Debug.Log("检测结果保存在" + resultPath);
        }
    }