Пример #1
0
        public static void Reset()
        {
            string[] variableGuids   = AssetDatabase.FindAssets("t:BaseVariable", new string[] { "Assets/Objects" });
            string[] collectionGuids = AssetDatabase.FindAssets("t:BaseCollection", new string[] { "Assets/Objects" });

            if (variableGuids.Length == 0 && collectionGuids.Length == 0)
            {
                return;
            }

            int count = 0;

            foreach (string guid in variableGuids)
            {
                string       path     = AssetDatabase.GUIDToAssetPath(guid);
                BaseVariable variable = (BaseVariable)AssetDatabase.LoadAssetAtPath(path, typeof(BaseVariable));
                if (!variable.ReadOnly)
                {
                    variable.ResetValue();
                    count++;
                }
            }
            foreach (string guid in collectionGuids)
            {
                string         path       = AssetDatabase.GUIDToAssetPath(guid);
                BaseCollection collection = (BaseCollection)AssetDatabase.LoadAssetAtPath(path, typeof(BaseCollection));
                if (!collection.ReadOnly)
                {
                    collection.Reset();
                    count++;
                }
            }

            if (count > 0)
            {
                Debug.LogFormat("Reset {0} writable variable{1}", count, count == 1 ? "" : "s");
            }
        }