Пример #1
0
        public static bool DrawcallOptimizemethod(string ASSET_PATH)
        {
            EditorUtility.DisplayProgressBar("DrawcallOptimizemethod in Path", "Collecting Object ", 0);
            string str = "";

            Debug.Log("DrawcallOptimizemethod----------------begin");
            int i   = 0;
            var gos =
                EnumAssets.EnumAllGameObjectDependenciesRecursive(
                    EnumAssets.EnumAssetAtPath <UnityEngine.Object>(ASSET_PATH));

            int total = 0;
            List <GameObject> staticList = new List <GameObject>();
            int k = 0;

            {
                // foreach(var c in gos)
                var __enumerator6 = (gos).GetEnumerator();
                while (__enumerator6.MoveNext())
                {
                    var c = __enumerator6.Current;
                    {
                        total++;
                    }
                }
            }
            {
                // foreach(var go in gos)
                var __enumerator8 = (gos).GetEnumerator();
                while (__enumerator8.MoveNext())
                {
                    var go = __enumerator8.Current;
                    {
                        // GameObject[] gameObjects = EnumAssets.EnumGameObjectRecursiveInCurrentSelection() as GameObject[];


                        EditorUtility.DisplayProgressBar("Draw Call Optimize", go.name,
                                                         k * 1.0f / total);

                        bool flag = false;

                        do
                        {
                            if (null != go.GetComponent <Animation>())
                            {
                                break;
                            }

                            if (null != go.GetComponent <SceneAnimationTrigger>())
                            {
                                break;
                            }

                            if (null != go.GetComponent <ParticleSystem>())
                            {
                                break;
                            }

                            if (null != go.GetComponent <ModelTextureAnimation>())
                            {
                                break;
                            }

                            flag = true;
                        } while (false);

                        go.gameObject.isStatic = flag;

                        if (go.GetComponent <SceneAnimationTrigger>())
                        {
                            SceneAnimationTrigger ada = go.GetComponent <SceneAnimationTrigger>();
                            foreach (var d in ada.KeyFrames)
                            {
                                staticList.Add(d.Target);

                                str += go.name + "\n";
                            }
                        }


                        k++;
                    }
                }
            }
            EditorUtility.ClearProgressBar();
            if (!string.IsNullOrEmpty(str))
            {
                Debug.Log(str);
            }
            {
                var __list9      = staticList;
                var __listCount9 = __list9.Count;
                for (int __i9 = 0; __i9 < __listCount9; ++__i9)
                {
                    var a = __list9[__i9];
                    {
                        a.isStatic = false;
                    }
                }
            }
            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();

            Debug.Log("DrawcallOptimizemethod-Total=[" + i.ToString() + "]---------------end");
            return(true);
        }