private void EntityPropertiesGUI() { Entity singleSelectedEntity = null; if (selectedEntities.Count == 1) { singleSelectedEntity = selectedEntities[0]; } EntityReferencePropertyManager.Reset(singleSelectedEntity); // could be null and that's fine (?) GUILayout.BeginVertical(GUI.skin.box); PropertiesObjectGUI(editEntity); GUILayout.EndVertical(); if (singleSelectedEntity != null && !(singleSelectedEntity is PlayerObject)) { GUILayout.BeginHorizontal(); if (GUIUtils.HighlightedButton("Clone")) { if (singleSelectedEntity is ObjectEntity) { ObjectEntity clone = (ObjectEntity)(singleSelectedEntity.Clone()); var pickerGUI = gameObject.AddComponent <FacePickerGUI>(); pickerGUI.voxelArray = voxelArray; pickerGUI.message = "Tap to place clone"; pickerGUI.pickAction = () => { if (!voxelArray.PlaceObject(clone)) { DialogGUI.ShowMessageDialog(gameObject, ActionBarGUI.OBJECT_NO_ROOM_ERROR); } }; } else if (singleSelectedEntity is Substance) { Substance clone = (Substance)(singleSelectedEntity.Clone()); clone.defaultPaint = voxelArray.GetSelectedPaint(); clone.defaultPaint.addSelected = false; clone.defaultPaint.storedSelected = false; voxelArray.substanceToCreate = clone; var createGUI = gameObject.AddComponent <CreateSubstanceGUI>(); createGUI.voxelArray = voxelArray; } } if (GUIUtils.HighlightedButton("Delete")) { DeleteButton(); } GUILayout.EndHorizontal(); } if (selectedEntities.Count > 1) { if (GUIUtils.HighlightedButton("Delete")) { DeleteButton(); } } TutorialGUI.TutorialHighlight("change sensor"); if (GUILayout.Button("Change Sensor")) { TypePickerGUI sensorMenu = gameObject.AddComponent <TypePickerGUI>(); sensorMenu.title = "Change Sensor"; sensorMenu.categories = new PropertiesObjectType[][] { GameScripts.sensors }; sensorMenu.handler = (PropertiesObjectType type) => { foreach (Entity entity in selectedEntities) { entity.sensor = (Sensor)type.Create(); } voxelArray.unsavedChanges = true; UpdateEditEntity(); }; } TutorialGUI.ClearHighlight(); GUILayout.BeginVertical(GUI.skin.box); PropertiesObjectGUI(editSensor, " Sensor"); GUILayout.EndVertical(); TutorialGUI.TutorialHighlight("add behavior"); if (GUILayout.Button("Add Behavior")) { NewBehaviorGUI behaviorMenu = gameObject.AddComponent <NewBehaviorGUI>(); behaviorMenu.title = "Add Behavior"; behaviorMenu.self = singleSelectedEntity; behaviorMenu.voxelArray = voxelArray; behaviorMenu.handler = (PropertiesObjectType behaviorType) => { foreach (Entity entity in selectedEntities) { EntityBehavior newBehavior = (EntityBehavior)behaviorType.Create(); // with multiple selected entities, NewBehaviorGUI doesn't check if behaviors // are valid for the selected entities if (newBehavior.targetEntity.entity == null && !newBehavior.targetEntityIsActivator && !newBehavior.BehaviorObjectType().rule(entity)) { continue; } entity.behaviors.Add(newBehavior); EntityPreviewManager.BehaviorUpdated(singleSelectedEntity, newBehavior); } voxelArray.unsavedChanges = true; UpdateEditEntity(); scrollVelocity = new Vector2(0, 2000 * editBehaviors.Count); // scroll to bottom }; } TutorialGUI.ClearHighlight(); Color guiBaseColor = GUI.backgroundColor; StoredEntityBehavior behaviorToRemove = null; foreach (StoredEntityBehavior storedBehavior in editBehaviors) { TutorialGUI.TutorialHighlight("behaviors"); Entity behaviorTarget = null; if (storedBehavior.sharedTarget) { behaviorTarget = storedBehavior.allBehaviors[0].targetEntity.entity; } if (behaviorTarget != null) { EntityReferencePropertyManager.Next(behaviorTarget); GUI.backgroundColor = guiBaseColor * EntityReferencePropertyManager.GetColor(); } EntityReferencePropertyManager.SetBehaviorTarget(behaviorTarget); GUILayout.BeginVertical(GUI.skin.box); GUI.backgroundColor = guiBaseColor; PropertiesObjectGUI(storedBehavior, " Behavior", () => EntityPreviewManager.BehaviorUpdated(singleSelectedEntity, storedBehavior.allBehaviors[0])); if (GUILayout.Button("Remove")) { behaviorToRemove = storedBehavior; } GUILayout.EndVertical(); // clear this every time, in case the next target is the same EntityReferencePropertyManager.SetBehaviorTarget(null); } if (behaviorToRemove != null) { foreach (Entity entity in selectedEntities) { foreach (EntityBehavior remove in behaviorToRemove.allBehaviors) { if (entity.behaviors.Remove(remove)) { break; } } } voxelArray.unsavedChanges = true; UpdateEditEntity(); EntityPreviewManager.BehaviorUpdated(singleSelectedEntity, behaviorToRemove.allBehaviors[0]); } if (mismatchedSelectedBehaviorCounts) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("(other behaviors...)", GUIStyleSet.instance.labelTitle); GUILayout.EndVertical(); } }
protected void EditGUI() { if (!voxelArray.FacesAreSelected()) { return; } TutorialGUI.TutorialHighlight("paint"); if (ActionBarButton(GUIIconSet.instance.paint)) { PaintGUI paintGUI = gameObject.AddComponent <PaintGUI>(); paintGUI.title = "Paint Faces"; paintGUI.handler = (VoxelFace paint) => { voxelArray.PaintSelectedFaces(paint); }; paintGUI.paint = voxelArray.GetSelectedPaint(); } TutorialGUI.ClearHighlight(); TutorialGUI.TutorialHighlight("create object"); if (ActionBarButton(GUIIconSet.instance.create)) { TypePickerGUI picker = gameObject.AddComponent <TypePickerGUI>(); picker.title = "Create"; picker.categories = new PropertiesObjectType[][] { GameScripts.entityTemplates, GameScripts.objectTemplates }; picker.categoryNames = new string[] { "Substance", "Object" }; picker.handler = (PropertiesObjectType type) => { if (typeof(Substance).IsAssignableFrom(type.type)) { Substance substance = (Substance)type.Create(); voxelArray.substanceToCreate = substance; var createGUI = gameObject.AddComponent <CreateSubstanceGUI>(); createGUI.voxelArray = voxelArray; } else if (typeof(ObjectEntity).IsAssignableFrom(type.type)) { ObjectEntity obj = (ObjectEntity)type.Create(); if (!voxelArray.PlaceObject(obj)) { DialogGUI.ShowMessageDialog(gameObject, OBJECT_NO_ROOM_ERROR); } } }; } TutorialGUI.ClearHighlight(); GUILayout.FlexibleSpace(); int moveCount = 0; if (touchListener.currentTouchOperation == TouchListener.TouchOperation.MOVE && touchListener.movingAxis is MoveAxis) { moveCount = Mathf.Abs(((MoveAxis)touchListener.movingAxis).moveCount); } if (moveCount != 0) { ActionBarLabel(moveCount.ToString()); } else { ActionBarLabel(SelectionString(voxelArray.selectionBounds.size)); } }