private void PerformDropUsingFirstPrefabInValidUnityPrefabCollection(List <GameObject> validUnityPrefabs) { GameObject firstValidUnityPrefab = GetFirstUnityPrefabFromValidUnityPrefabsCollection(validUnityPrefabs); PrefabCategory categoryWhichContainsPrefab = PrefabCategoryDatabase.Get().GetPrefabCategoryWhichContainsPrefab(firstValidUnityPrefab); if (categoryWhichContainsPrefab != null) { AssignPrefabToDestinationTileConnection(categoryWhichContainsPrefab.GetPrefabByUnityPrefab(firstValidUnityPrefab)); } else { Prefab firstValidPrefab = GetFirstPrefabFromValidPrefabsCollection(PrefabFactory.Create(validUnityPrefabs)); CreatePrefabToCategoryAssociationAndAssignPrefabToDestinationTileConnection(firstValidPrefab); } }
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(); }
public List <GameObject> MirrorGameObjectHierarchies(List <GameObject> sourceHierarchyRoots) { if (sourceHierarchyRoots.Count == 0) { return(new List <GameObject>()); } var mirroredHierarchies = new List <GameObject>(sourceHierarchyRoots.Count); if (IsActive) { Dictionary <GameObject, Prefab> unityPrefabsToOctavePrefabs = new Dictionary <GameObject, Prefab>(); foreach (var root in sourceHierarchyRoots) { GameObject unityPrefab = root.GetSourcePrefab(); Prefab octavePrefab = null; if (unityPrefab != null) { if (!unityPrefabsToOctavePrefabs.ContainsKey(unityPrefab)) { PrefabCategory prefabCategory = PrefabCategoryDatabase.Get().GetPrefabCategoryWhichContainsPrefab(unityPrefab); if (prefabCategory != null) { octavePrefab = prefabCategory.GetPrefabByUnityPrefab(unityPrefab); unityPrefabsToOctavePrefabs.Add(unityPrefab, octavePrefab); } } else { octavePrefab = unityPrefabsToOctavePrefabs[unityPrefab]; } } GameObject mirroredGameObjectHierarchy = MirrorGameObjectHierarchy(root, octavePrefab); if (mirroredGameObjectHierarchy != null) { mirroredHierarchies.Add(mirroredGameObjectHierarchy); } } } return(mirroredHierarchies); }