Beispiel #1
0
 protected override void PerformDrop()
 {
     if (ObjectPlacementPathTileConnectionSettingsChangeValidation.Validate(true))
     {
         List <GameObject> validUnityPrefabsInvolvedInDropOperation = PrefabValidator.GetValidPrefabsFromEntityCollection(DragAndDrop.objectReferences, false);
         if (validUnityPrefabsInvolvedInDropOperation.Count != 0)
         {
             PerformDropUsingFirstPrefabInValidUnityPrefabCollection(validUnityPrefabsInvolvedInDropOperation);
         }
     }
 }
        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);
        }
        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);
        }
        protected override void PerformDrop()
        {
            if (_dropDestination == DropDestination.Element)
            {
                if (_destinationDecorPaintBrushElement == null)
                {
                    return;
                }

                List <GameObject> validUnityPrefabsInvolvedInDropOperation = PrefabValidator.GetValidPrefabsFromEntityCollection(DragAndDrop.objectReferences, false);
                if (validUnityPrefabsInvolvedInDropOperation.Count != 0)
                {
                    PerformDropUsingFirstPrefabInValidUnityPrefabCollection(validUnityPrefabsInvolvedInDropOperation);
                }
            }
            else
            {
                if (_destinationBrush == null)
                {
                    return;
                }

                List <GameObject> validUnityPrefabs = PrefabValidator.GetValidPrefabsFromEntityCollection(DragAndDrop.objectReferences, false);
                if (validUnityPrefabs.Count != 0)
                {
                    UndoEx.RecordForToolAction(_destinationBrush);
                    foreach (GameObject unityPrefab in validUnityPrefabs)
                    {
                        DecorPaintObjectPlacementBrushElement newElement = _destinationBrush.CreateNewElement();

                        PrefabCategory categoryWhichContainsPrefab = PrefabCategoryDatabase.Get().GetPrefabCategoryWhichContainsPrefab(unityPrefab);
                        if (categoryWhichContainsPrefab != null)
                        {
                            newElement.Prefab = categoryWhichContainsPrefab.GetPrefabByUnityPrefab(unityPrefab);
                        }
                        else
                        {
                            Prefab prefab = PrefabFactory.Create(unityPrefab);
                            UndoEx.RecordForToolAction(_destinationBrush.DestinationCategoryForElementPrefabs);
                            PrefabWithPrefabCategoryAssociationQueue.Instance.Enqueue(PrefabWithPrefabCategoryAssociationFactory.Create(prefab, _destinationBrush.DestinationCategoryForElementPrefabs));
                            newElement.Prefab = prefab;
                        }
                    }
                }
            }

            Octave3DWorldBuilder.ActiveInstance.RepaintAllEditorWindows();
        }
        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);
        }
Beispiel #7
0
        private void ExtractAllValidDroppedPrefabs()
        {
            List <GameObject> validUnityPrefabs = PrefabValidator.GetValidPrefabsFromEntityCollection(DragAndDrop.objectReferences, false);

            _validDroppedPrefabs = PrefabFactory.Create(validUnityPrefabs);
        }