Esempio n. 1
0
    public static void OpenDialog()
    {
        var    cs         = EnumAssets.EnumComponentRecursiveInCurrentSelection <UISprite>();
        string resultFile = Application.dataPath + "/" + "Result.txt";

        FindImpl(cs, resultFile);
    }
Esempio n. 2
0
    //Animator如果不带Controller或是带Controller但是没有设置动作的 也直接去掉,不用再添加Animation
    public static bool FindUseAnimationPrefab()
    {
        string str = "";

        Debug.Log("Find Use Animation Prefab----------------begin");
        int i = 0;

        {
            // foreach(var c in EnumAssets.EnumComponentRecursiveInCurrentSelection<Animation>())
            var __enumerator6 = (EnumAssets.EnumComponentRecursiveInCurrentSelection <Animation>()).GetEnumerator();
            while (__enumerator6.MoveNext())
            {
                var c = __enumerator6.Current;
                {
                    if (c.GetClipCount() <= 0 || null == c.clip)
                    {
                        continue;
                    }

                    var go = c.gameObject;
                    str += AssetDatabase.GetAssetPath(go.GetInstanceID());
                    str += "[" + go.transform.FullPath() + "]\n";
                    i++;
                }
            }
        }
        if (!string.IsNullOrEmpty(str))
        {
            Debug.Log(str);
        }

        Debug.Log("Find Use Animation Prefab-Total=[" + i.ToString() + "]---------------end");
        return(true);
    }
Esempio n. 3
0
    private static List <UILabel> FindUILabel()
    {
        var list = new List <UILabel>();

        var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <UILabel>();

        int i         = 0;
        int processed = 0;
        int count     = cs.Count();

        {
            // foreach(var go in gos)
            var __enumerator2 = (cs).GetEnumerator();
            while (__enumerator2.MoveNext())
            {
                var c = __enumerator2.Current;
                {
                    EditorUtility.DisplayProgressBar("Find Unprocessed UILabel In Selection", c.gameObject.name, i * 1.0f / count);
                    i++;

                    if (!NeedProcess(c))
                    {
                        continue;
                    }

                    list.Add(c);
                }
            }
        }


        EditorUtility.ClearProgressBar();

        return(list);
    }
Esempio n. 4
0
    //Animator如果不带Controller或是带Controller但是没有设置动作的 也直接去掉,不用再添加Animation
    public static bool ChangeAnimatorToAnimation()
    {
        string str = "";

        Debug.Log("ChangeAnimatorToAnimation----------------begin");
        int i = 0;

        {
            // foreach(var go in EnumAssets.EnumComponentRecursiveInCurrentSelection<Animator>())
            var __enumerator1 = (EnumAssets.EnumComponentRecursiveInCurrentSelection <Animator>()).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var go = __enumerator1.Current;
                {
                    var g = go.gameObject;

                    AnimationOptimizing(go);


                    str += "[" + g.transform.FullPath() + "]\n";
                    i++;
                }
            }
        }
        if (!string.IsNullOrEmpty(str))
        {
            Debug.Log(str);
        }



        Debug.Log("ChangeAnimatorToAnimation-Total=[" + i.ToString() + "]---------------end");
        return(true);
    }
Esempio n. 5
0
    public static void Find()
    {
        Dictionary <string, List <string> > dictLog = new Dictionary <string, List <string> >();

        var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <UISprite>();

        EditorUtility.DisplayProgressBar("Export Atlas Reference", "Collecting Component", 0);

        int count = cs.Count();
        int i     = 0;
        int n     = 0;

        {
            // foreach(var c in cs)
            var __enumerator1 = (cs).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var c = __enumerator1.Current;
                {
                    i++;
                    EditorUtility.DisplayProgressBar("Export Atlas Reference", c.gameObject.name, i * 1.0f / count);

                    var atlas = c.atlas;
                    if (null == atlas)
                    {
                        continue;
                    }

                    List <string> listString = null;
                    if (!dictLog.TryGetValue(atlas.name, out listString))
                    {
                        listString = new List <string>();
                        dictLog.Add(atlas.name, listString);
                    }



                    n++;
                    var temp = "(" + c.spriteName + ")   " + c.transform.FullPath();
                    listString.Add(temp);
                }
            }
        }

        EditorUtility.ClearProgressBar();

        string log = string.Empty;

        foreach (var pair in dictLog)
        {
            foreach (var str in pair.Value)
            {
                log += "[" + pair.Key + "]" + str + "\n";
            }
        }

        Debug.Log(log);
        //Debug.Log("Using [" + AtlasName + "] Total=" + n.ToString() + "------------------------------------------end");
    }
Esempio n. 6
0
    public int Find1(ref string log)
    {
        if (string.IsNullOrEmpty(AtlasName))
        {
            return(0);
        }
        var temp           = AtlasName.ToLower();
        var spriteNameTemp = SpriteName.ToLower();
        var cs             = EnumAssets.EnumComponentRecursiveInCurrentSelection <UISprite>();

        EditorUtility.DisplayProgressBar("FindAtlasReference", "Collecting Component", 0);

        int count = cs.Count();
        int i     = 0;
        int n     = 0;

        {
            // foreach(var c in cs)
            var __enumerator1 = (cs).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var c = __enumerator1.Current;
                {
                    i++;
                    EditorUtility.DisplayProgressBar(AtlasName, c.gameObject.name, i * 1.0f / count);
                    var atlas = c.atlas;
                    if (null == atlas)
                    {
                        continue;
                    }
                    var atlasName = atlas.name.ToLower();
                    if (atlasName.Contains(temp))
                    {
                        if (string.IsNullOrEmpty(SpriteName))
                        {
                            n++;
                            log += "(" + atlas.name + "/" + c.spriteName + ")   " + c.transform.FullPath() + "\n";
                        }
                        else
                        {
                            var spritename = c.spriteName.ToLower();
                            if (spritename.Equals(spriteNameTemp))
                            {
                                n++;
                                log += "(" + atlas.name + "/" + c.spriteName + ")   " + c.transform.FullPath() + "\n";
                            }
                        }
                    }
                }
            }
        }

        return(n);
    }
Esempio n. 7
0
    public void Find3()
    {
        if (string.IsNullOrEmpty(AtlasName))
        {
            return;
        }
        var temp = AtlasName.ToLower();

        var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <UILabel>();

        EditorUtility.DisplayProgressBar("FindAtlasReference", "Collecting Component", 0);

        int    count = cs.Count();
        int    i     = 0;
        int    n     = 0;
        string log   = string.Empty;

        {
            // foreach(var c in cs)
            var __enumerator3 = (cs).GetEnumerator();
            while (__enumerator3.MoveNext())
            {
                var c = __enumerator3.Current;
                {
                    i++;
                    EditorUtility.DisplayProgressBar(AtlasName, c.gameObject.name, i * 1.0f / count);
                    var font = c.font;
                    if (null == font)
                    {
                        continue;
                    }
                    var atlas = font.atlas;
                    if (null == atlas)
                    {
                        continue;
                    }
                    var atlasName = font.atlas.name.ToLower();
                    if (atlasName.Contains(temp))
                    {
                        n++;

                        log += "(" + atlas.name + ")   " + c.transform.FullPath() + "\n";
                    }
                }
            }
        }

        if (!string.IsNullOrEmpty(log))
        {
            Debug.Log(log);
        }

        //Debug.Log("Using [" + AtlasName + "] Total=" + n.ToString() + "------------------------------------------end");
    }
Esempio n. 8
0
    public void Do()
    {
        if (null == TargetFont)
        {
            return;
        }
        var font = TargetFont as Font;

        if (null == font)
        {
            Logger.Debug("TargetFont is not fount");
            return;
        }

        var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <UIFont>();

        EditorUtility.DisplayProgressBar("FindAtlasReference", "Collecting Component", 0);

        int    count = cs.Count();
        int    i     = 0;
        string log   = string.Empty;

        {
            // foreach(var c in cs)
            var __enumerator1 = (cs).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var c = __enumerator1.Current;
                {
                    if (null == c.dynamicFont)
                    {
                        continue;
                    }
                    c.dynamicFont = font;

                    i++;
                    EditorUtility.DisplayProgressBar(font.name, c.gameObject.name, i * 1.0f / count);
                }
            }
        }

        if (!string.IsNullOrEmpty(log))
        {
            Debug.Log(log);
        }

        Debug.Log("Using [" + font.name + "] Total=" + i.ToString() + "------------------------------------------end");

        if (i > 0)
        {
            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();
        }
    }
Esempio n. 9
0
    //Animator如果不带Controller或是带Controller但是没有设置动作的 也直接去掉,不用再添加Animation
    public static bool ChangeAnimationClips()
    {
        string str = "";

        Debug.Log("ChangeAnimatorToAnimation----------------begin");
        int i = 0;

        {
            // foreach(var go in EnumAssets.EnumComponentRecursiveInCurrentSelection<Animation>())
            var __enumerator2 = (EnumAssets.EnumComponentRecursiveInCurrentSelection <Animation>()).GetEnumerator();
            while (__enumerator2.MoveNext())
            {
                var go = __enumerator2.Current;
                {
                    var g         = go.gameObject;
                    var animation = g.GetComponent <Animation>();

                    AnimationClip mCilp = animation.clip;

                    if (null != mCilp)
                    {
                        AnimationUtility.SetAnimationType(mCilp, ModelImporterAnimationType.Legacy);

                        if (AnimationUtility.GetAnimationClips(animation).Length == 0)
                        {
                            AnimationUtility.SetAnimationClips(animation, new AnimationClip[] { mCilp });
                        }

                        UnityEditor.EditorUtility.SetDirty(mCilp);
                    }

                    UnityEditor.EditorUtility.SetDirty(g);

                    str += "[" + g.transform.FullPath() + "]\n";
                    i++;
                }
            }
        }
        if (!string.IsNullOrEmpty(str))
        {
            Debug.Log(str);
        }



        Debug.Log("ChangeAnimatorToAnimation-Total=[" + i.ToString() + "]---------------end");
        return(true);
    }
Esempio n. 10
0
    public int Find2(ref string log)
    {
        if (string.IsNullOrEmpty(AtlasName))
        {
            return(0);
        }
        var temp = AtlasName.ToLower();

        var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <Particle2D>();

        EditorUtility.DisplayProgressBar("FindAtlasReference", "Collecting Component", 0);

        int count = cs.Count();
        int i     = 0;
        int n     = 0;

        {
            // foreach(var c in cs)
            var __enumerator3 = (cs).GetEnumerator();
            while (__enumerator3.MoveNext())
            {
                var c = __enumerator3.Current;
                {
                    i++;
                    EditorUtility.DisplayProgressBar(AtlasName, c.gameObject.name, i * 1.0f / count);
                    var atlas = c.atlas;
                    if (null == atlas)
                    {
                        continue;
                    }
                    var atlasName = atlas.name.ToLower();
                    if (atlasName.Contains(temp))
                    {
                        n++;
                        foreach (var str in c.sprites)
                        {
                            log += "(" + atlas.name + "/" + str + ")   " + c.transform.FullPath() + "\n";
                        }
                    }
                }
            }
        }

        return(n);
        //Debug.Log("Using [" + AtlasName + "] Total=" + n.ToString() + "------------------------------------------end");
    }
Esempio n. 11
0
        private static void SceneCheckupAndChangeRenderQueueMethod()
        {
            int processed = 0;

            try
            {
                var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <Renderer>();
                EditorUtility.DisplayProgressBar("Change Scene Render Queue", "Collecting Component", 0);

                int count = cs.Count();
                var layer = LayerMask.NameToLayer("ShadowReceiver");
                var q     = 2000 - 2; // Geometry - 2

                int idx = 0;
                {
                    // foreach(var c in cs)
                    var __enumerator2 = (cs).GetEnumerator();
                    while (__enumerator2.MoveNext())
                    {
                        var c = __enumerator2.Current;
                        {
                            idx++;
                            if (c.gameObject.layer != layer)
                            {
                                continue;
                            }
                            processed++;
                            EditorUtility.DisplayProgressBar("Change Scene Render Queue", c.gameObject.name, idx * 1.0f / count);
                            ProcessRenderQueue(c, q);
                        }
                    }
                }
                AssetDatabase.Refresh();
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
            finally
            {
                EditorUtility.ClearProgressBar();

                EditorUtility.DisplayDialog("Change Scene Render Queue", "processed=" + processed.ToString(), "OK");
            }
        }
Esempio n. 12
0
        //关闭T4m插件
        public static void T4MComponentDisablemethod()
        {
            {
                // foreach(var go in EnumAssets.EnumComponentRecursiveInCurrentSelection<T4MObjSC>())
                var __enumerator1 = (EnumAssets.EnumComponentRecursiveInCurrentSelection <T4MObjSC>()).GetEnumerator();
                while (__enumerator1.MoveNext())
                {
                    var go = __enumerator1.Current;
                    {
                        var g = go.gameObject;

                        Debug.Log(g.name + "T4MComponentDisable");
                        T4MObjSC mObjSc = g.GetComponent <T4MObjSC>();
                        mObjSc.enabled = false;
                    }
                }
            }
            AssetDatabase.Refresh();
        }
Esempio n. 13
0
    //优化资源
    public static void ChangeNPCShader()
    {
        var shaderId = Shader.Find("Scorpion/CharacterThrough").GetInstanceID();
        var shader   = Shader.Find("Scorpion/Character");

        var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <Renderer>();

        int count = cs.Count();
        int i     = 0;

        {
            // foreach(var c in cs)
            var __enumerator2 = (cs).GetEnumerator();
            while (__enumerator2.MoveNext())
            {
                var c = __enumerator2.Current;
                {
                    foreach (var m in c.sharedMaterials)
                    {
                        if (null != m)
                        {
                            if (m.shader.GetInstanceID() == shaderId)
                            {
                                m.shader = shader;
                            }
                        }
                    }
                    i++;
                    EditorUtility.DisplayProgressBar("Change Shader From CharacterThrough To Character", c.gameObject.name, i * 1.0f / count);
                }
            }
        }

        EditorUtility.ClearProgressBar();
        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();
    }
Esempio n. 14
0
    //Animator如果不带Controller或是带Controller但是没有设置动作的 也直接去掉,不用再添加Animation
    public static bool RemoveUselessAnimation()
    {
        string str = "";

        Debug.Log("Remove Animation----------------begin");
        int i = 0;

        {
            // foreach(var c in EnumAssets.EnumComponentRecursiveInCurrentSelection<Animation>())
            var __enumerator5 = (EnumAssets.EnumComponentRecursiveInCurrentSelection <Animation>()).GetEnumerator();
            while (__enumerator5.MoveNext())
            {
                var c = __enumerator5.Current;
                {
                    var go = c.gameObject;
                    if (c.GetClipCount() <= 0)
                    {
                        MonoBehaviour.DestroyImmediate(c, true);
                    }

                    str += "[" + go.transform.FullPath() + "]\n";
                    i++;
                }
            }
        }
        if (!string.IsNullOrEmpty(str))
        {
            Debug.Log(str);
        }

        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();

        Debug.Log("Remove Useless Animation-Total=[" + i.ToString() + "]---------------end");
        return(true);
    }
Esempio n. 15
0
 public static void CloseShadowsInSelection()
 {
     CloseShadows(EnumAssets.EnumComponentRecursiveInCurrentSelection <Renderer>());
 }
    public void Find1()
    {
        if (string.IsNullOrEmpty(SpriteName))
        {
            return;
        }
        var temp = SpriteName.ToLower();

        var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <UISprite>();

        EditorUtility.DisplayProgressBar("FindAtlasReference", "Collecting Component", 0);

        int count = cs.Count();
        int i     = 0;
        int n     = 0;

        string log = string.Empty;

        {
            // foreach(var c in cs)
            var __enumerator1 = (cs).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var c = __enumerator1.Current;
                {
                    i++;
                    EditorUtility.DisplayProgressBar(SpriteName, c.gameObject.name, i * 1.0f / count);

                    var spriteName = c.spriteName.ToLower();
                    if (null == c.atlas)
                    {
                        Debug.LogError("Error Atlas " + c.transform.FullPath());
                        continue;
                    }
                    if (-1 != spriteName.IndexOf(temp, StringComparison.OrdinalIgnoreCase))
                    {
                        n++;
                        log += "(" + c.atlas.name + "/" + c.spriteName + ")   " + c.transform.FullPath() + "\n";
                    }
                }
            }
        }

        if (!string.IsNullOrEmpty(log))
        {
            Debug.Log(log);
        }
        else
        {
            Debug.Log("No result");
        }
        string resultFile = Application.dataPath + "/" + "Result.txt";

        try
        {
            FileStream fs = new FileStream(resultFile, FileMode.Create);
            //获得字节数组
            byte[] data = System.Text.Encoding.Default.GetBytes(log);
            //开始写入
            fs.Write(data, 0, data.Length);
            //清空缓冲区、关闭流
            fs.Flush();
            fs.Close();

            Debug.Log(resultFile);
        }
        catch (IOException e)
        {
            Debug.Log(e.ToString());
        }
        EditorUtility.DisplayDialog("Find Sprite Reference:" + n, resultFile, "OK");
    }
Esempio n. 17
0
    public static void Find()
    {
        Dictionary <string, List <string> > dictLog = new Dictionary <string, List <string> >();

        var cs = EnumAssets.EnumComponentRecursiveInCurrentSelection <UISprite>();

        EditorUtility.DisplayProgressBar("Export Atlas Reference", "Collecting Component", 0);

        int count = cs.Count();
        int i     = 0;
        int n     = 0;

        {
            // foreach(var c in cs)
            var __enumerator1 = (cs).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var c = __enumerator1.Current;
                {
                    i++;
                    EditorUtility.DisplayProgressBar("Export Atlas Reference", c.gameObject.name, i * 1.0f / count);

                    var atlas = c.atlas;
                    if (null == atlas)
                    {
                        continue;
                    }

                    List <string> listString = null;
                    if (!dictLog.TryGetValue(atlas.name, out listString))
                    {
                        listString = new List <string>();
                        dictLog.Add(atlas.name, listString);
                    }



                    n++;
                    var temp = "(" + c.spriteName + ")   " + c.transform.FullPath();
                    listString.Add(temp);
                }
            }
        }

        EditorUtility.ClearProgressBar();

        string log = string.Empty;

        foreach (var pair in dictLog)
        {
            foreach (var str in pair.Value)
            {
                log += "[" + pair.Key + "]" + str + "\n";
            }
        }

        if (!string.IsNullOrEmpty(log))
        {
            Debug.Log(log);
        }
        else
        {
            Debug.Log("No result");
        }
        string resultFile = Application.dataPath + "/" + "Result.txt";

        try
        {
            FileStream fs = new FileStream(resultFile, FileMode.Create);
            //获得字节数组
            byte[] data = System.Text.Encoding.Default.GetBytes(log);
            //开始写入
            fs.Write(data, 0, data.Length);
            //清空缓冲区、关闭流
            fs.Flush();
            fs.Close();

            Debug.Log(resultFile);
        }
        catch (IOException e)
        {
            Debug.Log(e.ToString());
        }
        EditorUtility.DisplayDialog("Find Atlas Reference:" + n, resultFile, "OK");
        //Debug.Log("Using [" + AtlasName + "] Total=" + n.ToString() + "------------------------------------------end");
    }