Пример #1
0
        public static List <GameObject> GetValidPrefabsFromPrefabCollection(List <GameObject> prefabs, bool logWarningMessages)
        {
            var validPrefabs = new List <GameObject>();

            foreach (GameObject prefab in prefabs)
            {
                if (PrefabValidator.ValidatePrefab(prefab, logWarningMessages))
                {
                    validPrefabs.Add(prefab);
                }
            }

            return(validPrefabs);
        }
        private static List <GameObject> GetValidPrefabsWhichExistAmongstAssets(List <UnityEngine.Object> assets)
        {
            var validPrefabs = new List <GameObject>();

            foreach (var asset in assets)
            {
                GameObject prefabFromAsset = asset as GameObject;
                if (PrefabValidator.ValidatePrefab(prefabFromAsset, false))
                {
                    validPrefabs.Add(prefabFromAsset);
                }
            }

            return(validPrefabs);
        }
Пример #3
0
        public static List <GameObject> GetValidPrefabsFromEntityCollection(UnityEngine.Object[] entities, bool logWarningMessages)
        {
            var validPrefabs = new List <GameObject>(entities.Length);

            foreach (var entity in entities)
            {
                GameObject prefab = entity as GameObject;
                if (PrefabValidator.ValidatePrefab(prefab, true))
                {
                    validPrefabs.Add(prefab);
                }
            }

            return(validPrefabs);
        }
        private static List <GameObject> GetValidPrefabsWhichExistAmongstAssets(List <string> assetPaths, bool showProgressBar = false)
        {
            var validPrefabs = new List <GameObject>();

            if (showProgressBar)
            {
                for (int pathIndex = 0; pathIndex < assetPaths.Count; ++pathIndex)
                {
                    string assetPath = assetPaths[pathIndex];
                    EditorUtility.DisplayProgressBar("Loading assets", "Please wait... (" + assetPath + ")", (pathIndex + 1) / (float)assetPaths.Count);
                    if (IsAssetPrefab(assetPath))
                    {
                        GameObject prefab = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
                        if (PrefabValidator.ValidatePrefab(prefab, false))
                        {
                            validPrefabs.Add(prefab);
                        }
                    }
                }
            }
            else
            {
                foreach (string assetPath in assetPaths)
                {
                    if (IsAssetPrefab(assetPath))
                    {
                        GameObject prefab = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
                        if (PrefabValidator.ValidatePrefab(prefab, false))
                        {
                            validPrefabs.Add(prefab);
                        }
                    }
                }
            }

            return(validPrefabs);
        }