Ejemplo n.º 1
0
    public static bool RemoveAllAnimationClipInCurrentSelection()
    {
        string str = "";

        Debug.Log("Remove All AnimationClip----------------begin");
        var gos = EnumAssets.EnumGameObjectInCurrentSelection();

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

        {
            // foreach(var go in gos)
            var __enumerator9 = (gos).GetEnumerator();
            while (__enumerator9.MoveNext())
            {
                var go = __enumerator9.Current;
                {
                    EditorUtility.DisplayProgressBar("Remove Animation Clip In Selection", go.name, i * 1.0f / count);
                    i++;

                    var c = go.GetComponent <Animation>();

                    if (null == c)
                    {
                        continue;
                    }
                    c.clip = null;

                    if (c.GetClipCount() <= 0)
                    {
                        continue;
                    }

                    List <string> strList = new List <string>();
                    foreach (var clip in c)
                    {
                        var aniState = clip as AnimationState;
                        if (null != aniState)
                        {
                            strList.Add(aniState.clip.name);
                        }
                    }
                    foreach (var name in strList)
                    {
                        c.RemoveClip(name);
                    }

                    str += AssetDatabase.GetAssetPath(go.GetInstanceID());
                    str += "[" + go.transform.FullPath() + "]\n";


                    processed++;
                }
            }
        }

        EditorUtility.ClearProgressBar();

        if (!string.IsNullOrEmpty(str))
        {
            Debug.Log(str);
        }
        if (processed > 0)
        {
            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();
        }

        Debug.Log("Find Use Animation Prefab-Total=[" + processed.ToString() + "]---------------end");
        return(true);
    }