public override void OnInspectorGUI() { if (SceneUpdater.IsActive) { aScaling.GizmoPreviewState = (GizmoPreviewState)EditorGUILayout.EnumPopup("Gizmo visibility", aScaling.GizmoPreviewState); EditorGUILayout.Space(); aScaling.uniformScaling = EditorGUILayout.Toggle("Uniform scale", aScaling.uniformScaling); aScaling.maxVal = EditorGUILayout.DelayedIntField("Interval max value", aScaling.maxVal); aScaling.maxVal = Mathf.Max(1, aScaling.maxVal); EditorGUILayout.Space(); if (aScaling.uniformScaling) { LabeledMinMaxSlider(ref aScaling.uniformMinSize, ref aScaling.uniformMaxSize, aScaling.maxVal); } else { LabeledMinMaxSlider(ref aScaling.minSize.x, ref aScaling.maxSize.x, aScaling.maxVal); LabeledMinMaxSlider(ref aScaling.minSize.y, ref aScaling.maxSize.y, aScaling.maxVal); LabeledMinMaxSlider(ref aScaling.minSize.z, ref aScaling.maxSize.z, aScaling.maxVal); } } SceneUpdater.UpdateScene(); }
private void LoadChunk() { Restore(); ShowSaveFirstDialog(); System.IO.Directory.CreateDirectory(GlobalPaths.AbsoluteChunkPath); //Create folders if they don't yet exist System.IO.Directory.CreateDirectory(GlobalPaths.AbsoluteHallwayPath); //Create folders if they don't yet exist string title = IsChunk ? "Load Chunk" : "Load Hallway"; string dialogPath = EditorUtility.OpenFilePanel(title, AbsolutePath, "prefab"); if (dialogPath.Length > 0) { //Since the dialog outputs the complete path, which Resources.Load doesn't work with, a relative path is used //Resources.Load only works with files inside the Resources folder. The path therefore only has to contain the folder the chunks //Are stored in+ string parentFolder = Path.GetDirectoryName(dialogPath).Split(new string[] { "Resources" }, StringSplitOptions.None)[1]; string filePath = parentFolder + "/" + System.IO.Path.GetFileNameWithoutExtension(dialogPath); if (filePath.StartsWith("/")) { filePath = filePath.Remove(0, 1); } //Debug.Log (filePath); //OriginalChunk.tag = "ChunkRemove"; DestroyMultiple(SceneObjects); OriginalObject = null; //OriginalChunk = (GameObject)GameObject.Instantiate (Resources.Load (filePath)); OriginalObject = (GameObject)PrefabUtility.InstantiatePrefab(Resources.Load(filePath)); OriginalObject.transform.position = Vector3.zero; //PrefabUtility.DisconnectPrefabInstance(OriginalChunk); SceneUpdater.UpdateScene(); } }
public override void OnInspectorGUI() { if (SceneUpdater.IsActive) { stickTo.GizmoPreviewState = (GizmoPreviewState)EditorGUILayout.EnumPopup("Gizmo visibility", stickTo.GizmoPreviewState); EditorGUILayout.Space(); if (!ColliderFound()) { EditorGUILayout.HelpBox("StickTo needs a collider on this or any child Game Objects in order to work.\n" + "If you are using a Wildcard Property, please ensure the objects you are instantiating have a Collider attached to them.", MessageType.Info); } EditorGUILayout.LabelField("Direction", stickTo.stickDirection.ToString()); EditorGUILayout.LabelField("Sticks to", SticksTo()); EditorGUILayout.Space(); stickTo.distance = Mathf.Min(stickTo.MaxDistance, stickTo.distance); stickTo.distance = EditorGUILayout.Slider("Distance", stickTo.distance, 0f, stickTo.MaxDistance); stickTo.tolerance = EditorGUILayout.Slider("Tolerance", stickTo.tolerance, 0.05f, 0.95f); stickTo.distance = Mathf.Max(0f, stickTo.distance); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Apply Position")) { stickTo.Apply(); } EditorGUILayout.EndHorizontal(); SceneUpdater.UpdateScene(); } }
public async Task <Unit> Handle(DeletePollRequest request, CancellationToken cancellationToken) { var(conferenceId, pollId) = request; var poll = await _repository.GetPoll(conferenceId, pollId); if (poll == null) { return(Unit.Value); } await _repository.DeletePollAndState(conferenceId, pollId); var deletedAnswers = await _repository.DeletePollAnswers(conferenceId, pollId); await _mediator.Send(new UpdateParticipantSubscriptionsOfPollRequest(conferenceId, poll)); await SceneUpdater.UpdateScene(_mediator, conferenceId, poll.RoomId); foreach (var participantId in deletedAnswers.Keys) { await _mediator.Send(new UpdateSynchronizedObjectRequest(conferenceId, SynchronizedPollAnswers.SyncObjId(participantId))); } return(Unit.Value); }
public async Task <string> Handle(CreatePollRequest request, CancellationToken cancellationToken) { var(conferenceId, pollInstruction, pollConfig, initialState, roomId) = request; var pollId = Guid.NewGuid().ToString("N"); var timestamp = DateTimeOffset.UtcNow; var poll = new Poll(pollId, pollInstruction, pollConfig, roomId, timestamp); await _repository.CreatePoll(conferenceId, poll); await _repository.SetPollState(conferenceId, pollId, initialState); if (!await _openConferenceRepository.IsOpen(request.ConferenceId)) { await _repository.DeletePollAndState(conferenceId, pollId); throw ConferenceError.ConferenceNotOpen.ToException(); } await _mediator.Send(new UpdateParticipantSubscriptionsOfPollRequest(conferenceId, poll)); await SceneUpdater.UpdateScene(_mediator, conferenceId, roomId); return(pollId); }
//Remvoes any old copy of the chunk and sets the original, abstract chunk active private void Restore() { DestroyMultiple(SceneInstances); //Destroy the generated chunk SetObjectActive(true); SceneUpdater.SetActive(true); SceneUpdater.UpdateScene(); }
public void OnSceneGUI() { hallway.PositionUpdate(); int[] gridSize = hallway.GridSize; for (int i = 0; i < gridSize[0]; i++) { for (int j = 0; j < gridSize[1]; j++) { Handles.color = StateColor(i, j); Vector3 absolutePosition = hallway.GetPosition(i, j); if (hallway.HasAdjacents(i, j) && Handles.Button(absolutePosition, Quaternion.identity, 0.5f, 0.5f, Handles.CubeHandleCap)) { hallway.SwitchState(i, j, MaskState.FILL); hallway.DrawGeometry(); SceneUpdater.UpdateScene(); } var state = hallway.GetState(i, j); if (NeedsToDrawCube(state)) { Handles.color = ColorForState(state); Vector3 cubePosition = new Vector3(absolutePosition.x, DoorDefinition.GlobalSize / 2f, absolutePosition.z); Handles.CubeHandleCap(0, cubePosition, Quaternion.identity, DoorDefinition.GlobalSize, EventType.Repaint); } } } }
public override void OnInspectorGUI() { if (SceneUpdater.IsActive) { sArray.GizmoPreviewState = (GizmoPreviewState)EditorGUILayout.EnumPopup("Gizmo visibility", sArray.GizmoPreviewState); EditorGUILayout.Space(); if (sArray.hasOverflow && !sArray.autoFill) { EditorGUILayout.HelpBox("Overflow detected. Please reduce the amount of copies.", MessageType.Error); } sArray.editorSeed = EditorGUILayout.IntField("Editor seed", sArray.editorSeed); EditorGUILayout.Space(); sArray.areaType = (AreaType)EditorGUILayout.EnumPopup("Type of area", sArray.areaType); if (sArray.areaType == AreaType.SPHERICAL) { sArray.radius = EditorGUILayout.FloatField("Radius", sArray.radius); sArray.radius = Mathf.Max(0f, sArray.radius); } if (sArray.areaType == AreaType.RECT) { sArray.rectArea = EditorGUILayout.Vector2Field("Area size", sArray.rectArea); } EditorGUILayout.Space(); sArray.autoFill = EditorGUILayout.Toggle("Auto fill", sArray.autoFill); if (sArray.autoFill) { //Prevent overlapping has to be true in order to cause an overflow that stops cultivating the radius sArray.preventOverlapping = true; } else { sArray.preventOverlapping = EditorGUILayout.Toggle("Prevent overlapping", sArray.preventOverlapping); //Duplicate count is variable and cannot be set sArray.duplicateCount = EditorGUILayout.IntField("Duplicates", sArray.duplicateCount, GUILayout.ExpandWidth(false)); } if (sArray.preventOverlapping || sArray.autoFill) { sArray.spacing = EditorGUILayout.FloatField("Spacing", sArray.spacing); sArray.spacing = Mathf.Max(0f, sArray.spacing); } sArray.duplicateCount = Mathf.Max(0, sArray.duplicateCount); } SceneUpdater.UpdateScene(); }
public override void OnInspectorGUI() { abstractMesh.meshShape = (MeshShape)EditorGUILayout.EnumPopup("Shape", abstractMesh.meshShape); EditorGUILayout.Space(); if (abstractMesh.HasAbstractBounds) { EditorGUILayout.HelpBox("Extends is currently modified by AbstractBounds", MessageType.Info); } GUI.enabled = !abstractMesh.HasAbstractBounds; abstractMesh.extends = EditorGUILayout.Vector3Field("Extends", abstractMesh.extends); GUI.enabled = true; abstractMesh.externBounds = (AbstractBounds)EditorGUILayout.ObjectField("Abstract Bounds", abstractMesh.externBounds, typeof(AbstractBounds), true) as AbstractBounds; if (abstractMesh.meshShape == MeshShape.CYLINDER) { abstractMesh.iterations = (int)EditorGUILayout.Slider("Iterations", abstractMesh.iterations, 3, 20); } if (abstractMesh.meshShape == MeshShape.TERRAIN) { abstractMesh.terrainScale = EditorGUILayout.Slider("Scale", abstractMesh.terrainScale, 0.1f, 10); abstractMesh.terrainCellSize = EditorGUILayout.Slider("Cell Size", abstractMesh.terrainCellSize, 0.1f, 10); abstractMesh.terrainElevation = EditorGUILayout.Slider("Elevation", abstractMesh.terrainElevation, 0.1f, 10); abstractMesh.zeroEdges = EditorGUILayout.Toggle("Zero Edges", abstractMesh.zeroEdges); } EditorGUILayout.Space(); abstractMesh.material = EditorGUILayout.ObjectField("Material", abstractMesh.material, typeof(Material), false) as Material; abstractMesh.tiling = EditorGUILayout.FloatField("Tiling", abstractMesh.tiling); EditorGUILayout.Space(); if (GUILayout.Button("Break Shared Mesh")) { abstractMesh.BreakSharedMeshLink(); } SceneUpdater.UpdateScene(); }
private void CreateNewChunk() { Restore(); ShowSaveFirstDialog(); DestroyMultiple(SceneObjects); UnityEngine.Object newPrefab = Resources.Load(RelativePath + "/" + NewName); if (newPrefab != null) { OriginalObject = (GameObject)GameObject.Instantiate(newPrefab); SceneUpdater.UpdateScene(); } else { if (IsChunk) { Debug.LogError("Default Chunk could not be loaded. Your Chunks folder must contain a default Chunk named \"NewChunk\""); } else { Debug.LogError("Default Hallway could not be loaded. Your Hallways folder must contain a Prefab named \"HallwayTemplate\""); } } }
public override void OnInspectorGUI() { if (SceneUpdater.IsActive) { lArray.GizmoPreviewState = (GizmoPreviewState)EditorGUILayout.EnumPopup("Gizmo visibility", lArray.GizmoPreviewState); EditorGUILayout.Space(); lArray.autoCount = EditorGUILayout.Toggle("Autocount", lArray.autoCount); lArray.closeGap = !EditorGUILayout.Toggle("Auto spacing", !lArray.closeGap); if (lArray.autoCount && !lArray.closeGap) { lArray.spacing = EditorGUILayout.FloatField("Spacing", lArray.spacing); lArray.spacing = Mathf.Max(lArray.spacing, 0f); } else if (!lArray.autoCount) { lArray.duplicateCount = EditorGUILayout.IntField("Copies", lArray.duplicateCount); lArray.duplicateCount = Mathf.Max(lArray.duplicateCount, 0); } } SceneUpdater.UpdateScene(); }
public override void OnInspectorGUI() { if (SceneUpdater.IsActive) { aPosition.GizmoPreviewState = (GizmoPreviewState)EditorGUILayout.EnumPopup("Gizmo visibility", aPosition.GizmoPreviewState); EditorGUILayout.Space(); aPosition.useRaycast = EditorGUILayout.Toggle("Raycast", aPosition.useRaycast); if (aPosition.useRaycast) { aPosition.useAvailableSpace = EditorGUILayout.Toggle("Fill", aPosition.useAvailableSpace); } if (!aPosition.useAvailableSpace || !aPosition.useRaycast) { aPosition.minValue = EditorGUILayout.FloatField("Min", aPosition.minValue); aPosition.maxValue = EditorGUILayout.FloatField("Max", aPosition.maxValue); //Clamping aPosition.minValue = Mathf.Max(0f, aPosition.minValue); aPosition.maxValue = Mathf.Max(0f, aPosition.maxValue); } SceneUpdater.UpdateScene(); } }
public override void OnInspectorGUI() { if (SceneUpdater.IsActive) { wildcard.GizmoPreviewState = (GizmoPreviewState)EditorGUILayout.EnumPopup("Gizmo visibility", wildcard.GizmoPreviewState); EditorGUILayout.Space(); wildcard.wildcardTarget = (WildcardTarget)EditorGUILayout.EnumPopup("Target", wildcard.wildcardTarget); if (wildcard.wildcardTarget == WildcardTarget.CHILDREN) { SerializedProperty children = getTarget.FindProperty("children"); EditorGUILayout.Space(); for (int i = 0; i < children.arraySize; i++) { SerializedProperty child = children.GetArrayElementAtIndex(i); SerializedProperty childName = child.FindPropertyRelative("name"); SerializedProperty childChance = child.FindPropertyRelative("chance"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(childName.stringValue); childChance.intValue = EditorGUILayout.IntField(childChance.intValue); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); if (GUILayout.Button("Update")) { wildcard.UpdateChildren(); } getTarget.ApplyModifiedProperties(); } else { //Update the list getTarget.Update(); showAssets = EditorGUILayout.Foldout(showAssets, "Assets"); if (showAssets) { int currentSum = wildcard.SumUpChances(); //Show a warning, if there are null refs in the asset list if (NullRefsInList()) { EditorGUILayout.HelpBox("Null references will result in an empty object.", MessageType.Warning); } //Show a warning if the chances don't sum up to 100 if (currentSum != 100) { EditorGUILayout.HelpBox("Probabilities have to sum up to a total of 100%" + "\nCurrent sum: " + currentSum.ToString() + "\nDelta: " + (100 - currentSum).ToString(), MessageType.Error); } EditorGUILayout.Space(); //Draw list with object picker, int picker, deletion button for (int i = 0; i < assetList.arraySize; i++) { EditorGUILayout.BeginHorizontal(); SerializedProperty wildcardRef = assetList.GetArrayElementAtIndex(i); SerializedProperty assetRef = wildcardRef.FindPropertyRelative("Asset"); SerializedProperty chanceRef = wildcardRef.FindPropertyRelative("Chance"); assetRef.objectReferenceValue = (GameObject)EditorGUILayout.ObjectField(assetRef.objectReferenceValue, typeof(GameObject), true); chanceRef.intValue = EditorGUILayout.IntField(chanceRef.intValue, GUILayout.Width(30)); if (GUILayout.Button("x", GUILayout.Width(20))) { assetList.DeleteArrayElementAtIndex(i); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } if (GUILayout.Button("Add asset")) { assetList.InsertArrayElementAtIndex(assetList.arraySize); } } //Apply all changes to the list getTarget.ApplyModifiedProperties(); EditorGUILayout.Space(); //Slider to preview the objects EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Preview index:"); wildcard.selectedIndex = (int)EditorGUILayout.Slider(wildcard.selectedIndex, 0, wildcard.chancesList.Count - 1); EditorGUILayout.EndHorizontal(); //Selected Asset as preview wildcard.selectedIndex = Mathf.Clamp(wildcard.selectedIndex, 0, Mathf.Max(0, wildcard.chancesList.Count - 1)); if (wildcard.chancesList.Count > 0) { GameObject asset = wildcard.chancesList [wildcard.selectedIndex].Asset; string previewName = asset != null ? asset.name : "null"; EditorGUILayout.LabelField("Asset: " + previewName); } else { EditorGUILayout.LabelField("Nothing to preview"); } } SceneUpdater.UpdateScene(); } }
public override void OnInspectorGUI() { if (SceneUpdater.IsActive) { aValue.GizmoPreviewState = (GizmoPreviewState)EditorGUILayout.EnumPopup("Gizmo visibility", aValue.GizmoPreviewState); EditorGUILayout.Space(); aValue.component = EditorGUILayout.ObjectField("Target", aValue.component, typeof(Component), true) as Component; EditorGUILayout.Space(); if (aValue.component != null) { serialTarget = new SerializedObject(aValue); colorList = serialTarget.FindProperty("randomColors"); //Only allow to modify components of the gameobject this abstract value is attached to //This will prevent bugs with the execution order if (IsComponentOfOtherGO(aValue.component)) { Debug.LogWarning("Abstract value may only modify components of the Game Object it is attached to."); aValue.component = null; } GetComponentsVariables(); aValue.selectedIndex = EditorGUILayout.Popup("Variable", aValue.selectedIndex, variableNames.ToArray()); aValue.showPreview = EditorGUILayout.Toggle("Show preview", aValue.showPreview); if (aValue.prevComponent == null || aValue.prevComponent != aValue.component) { aValue.selectedIndex = 0; aValue.varInfo = variableInfos [aValue.selectedIndex]; } if (aValue.prevSelectedIndex == -1 || aValue.prevSelectedIndex != aValue.selectedIndex) { aValue.varInfo = variableInfos [aValue.selectedIndex]; } EditorGUILayout.Space(); EditorGUILayout.LabelField("Internal Type", variableInfos [aValue.selectedIndex].ShortType.ToString()); if (aValue.IsSelectedOfType(typeof(int))) { aValue.minIntVal = EditorGUILayout.IntField("Min value", aValue.minIntVal); aValue.maxIntVal = EditorGUILayout.IntField("Max value", aValue.maxIntVal); } else if (aValue.IsSelectedOfType(typeof(Single))) { aValue.minFloatVal = EditorGUILayout.FloatField("Min value", aValue.minFloatVal); aValue.maxFloatVal = EditorGUILayout.FloatField("Max value", aValue.maxFloatVal); } else if (aValue.IsSelectedOfType(typeof(Vector3))) { aValue.minVec3Val = EditorGUILayout.Vector3Field("Min value", aValue.minVec3Val); aValue.maxVec3Val = EditorGUILayout.Vector3Field("Max value", aValue.maxVec3Val); } else if (aValue.IsSelectedOfType(typeof(Vector2))) { aValue.minVec2Val = EditorGUILayout.Vector2Field("Min value", aValue.minVec2Val); aValue.maxVec2Val = EditorGUILayout.Vector2Field("Max value", aValue.maxVec2Val); } else if (aValue.IsSelectedOfType(typeof(bool))) { } else if (aValue.IsSelectedOfType(typeof(Color))) { for (int i = 0; i < colorList.arraySize; i++) { SerializedProperty argbColorRef = colorList.GetArrayElementAtIndex(i); Color colValue = aValue.Vec4ToCol(argbColorRef.vector4Value); EditorGUILayout.BeginHorizontal(); colValue = EditorGUILayout.ColorField(colValue); argbColorRef.vector4Value = aValue.ColToVec4(colValue); if (GUILayout.Button("x", GUILayout.Width(20))) { colorList.DeleteArrayElementAtIndex(i); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); if (GUILayout.Button("Add color")) { colorList.InsertArrayElementAtIndex(colorList.arraySize); } serialTarget.ApplyModifiedProperties(); } else { EditorGUILayout.HelpBox("Type not supported.", MessageType.Info); } if (GUILayout.Button("Test")) { aValue.Generate(); } aValue.prevSelectedIndex = aValue.selectedIndex; aValue.prevComponent = aValue.component; } } SceneUpdater.UpdateScene(); }
public override void OnInspectorGUI() { if (SceneUpdater.IsActive) { abstractBounds.GizmoPreviewState = (GizmoPreviewState)EditorGUILayout.EnumPopup("Gizmo visibility", abstractBounds.GizmoPreviewState); EditorGUILayout.Space(); if (abstractBounds.IsChunk) { showInfo = EditorGUILayout.Foldout(showInfo, "Show info"); if (showInfo) { if (abstractBounds.IsConstrainedByDoors) { EditorGUILayout.HelpBox("Please note, that the size is constrained by the doors defined by the DoorManager component", MessageType.Info); } EditorGUILayout.HelpBox("A Chunk's size always snaps to a grid defined by the size of doors.", MessageType.Info); } } EditorGUILayout.Space(); //ITransformable[] children = abstractBounds.gameObject.GetComponents<ITransformable> (); abstractBounds.hasFixedSize = EditorGUILayout.Toggle("Fixed size", abstractBounds.hasFixedSize); EditorGUILayout.Space(); if (!abstractBounds.IsChunk) { if (!abstractBounds.hasFixedSize) { ConditionalVectorField("Minimal", ref abstractBounds.minSize); ConditionalVectorField("Maximal", ref abstractBounds.maxSize); } else { ConditionalVectorField("Size", ref abstractBounds.minSize); } } else { if (!abstractBounds.hasFixedSize) { ConditionalVectorField("Minimal", ref abstractBounds.chunkBounds.MinSize); ConditionalVectorField("Maximal", ref abstractBounds.chunkBounds.MaxSize); } else { ConditionalVectorField("Size", ref abstractBounds.chunkBounds.MinSize); } EditorGUILayout.LabelField("Rounded size", abstractBounds.Size.ToString()); } EditorGUILayout.Space(); //Both options are only relevant, when the size is variable and therefore defined by min and max values if (!abstractBounds.hasFixedSize) { abstractBounds.lerp = EditorGUILayout.Slider("Preview lerp", abstractBounds.lerp, 0f, 1f); abstractBounds.keepAspectRatio = EditorGUILayout.Toggle("Keep aspect ratio", abstractBounds.keepAspectRatio); } EditorGUILayout.Space(); if (!abstractBounds.IsChunk) { showStretch = EditorGUILayout.Foldout(showStretch, "Stretch"); EditorGUILayout.Space(); if (showStretch) { for (int i = 0; i < 3; i++) { StretchInfo stretch = abstractBounds.StretchInfos [i]; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Stretch on"); EditorGUILayout.SelectableLabel(stretch.Label, GUILayout.Width(20)); stretch.Active = EditorGUILayout.Toggle(stretch.Active, GUILayout.ExpandWidth(false)); EditorGUILayout.SelectableLabel("Percent", GUILayout.Width(60)); stretch.Percent = EditorGUILayout.FloatField(stretch.Percent, GUILayout.ExpandWidth(true)); stretch.Percent = Mathf.Clamp(stretch.Percent, 0f, 1f); EditorGUILayout.EndHorizontal(); } } } //Update bounds of all objects implementing the interface //ApplySize (children, abstractBounds); SceneUpdater.UpdateScene(); } }
public override void OnInspectorGUI() { buttonStyle = new GUIStyle("button"); buttonStyle.fontSize = 13; buttonStyle.fixedHeight = 18; if (SceneUpdater.IsActive) { serDoorDefinitions = new SerializedObject(doorDefinitions); serDoorList = serDoorDefinitions.FindProperty("doors"); int selectedIndex = doorDefinitions.doors.IndexOf(selectedDoor); SerializedProperty serPreviewDoors = serDoorDefinitions.FindProperty("previewDoors"); //PREVIEW DOOR toggle EditorGUILayout.Space(); string onOff = serPreviewDoors.boolValue ? ": On" : ": Off"; EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Mesh preview" + onOff, buttonStyle)) { bool prevPreviewVal = serPreviewDoors.boolValue; serPreviewDoors.boolValue = !serPreviewDoors.boolValue; } if (!SceneUpdater.HideGizmos) { EditorGUILayout.Space(); if (GUILayout.Button("-> Enter edit mode", buttonStyle)) { SceneUpdater.HideGizmos = true; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (SceneUpdater.HideGizmos) { EditorGUILayout.Space(); //SerializedProperty serDoorDefSize = serDoorDefinitions.FindProperty ("doorSize"); //float prevSize = serDoorDefSize.floatValue; //serDoorDefSize.floatValue = (float)EditorGUILayout.IntField ("Door size", (int)serDoorDefSize.floatValue); //doorDefinitions.AreDoorsDirty |= prevSize != serDoorDefSize.floatValue; //The doorsize should never be larger thant the actual room //serDoorDefSize.floatValue = Mathf.Clamp (serDoorDefSize.floatValue, 1f, doorDefinitions.AbstractBounds.minSize.y); //serDoorDefSize.floatValue = 2f; EditorGUILayout.Space(); SerializedProperty serMinCount = serDoorDefinitions.FindProperty("minCount"); SerializedProperty serMaxCount = serDoorDefinitions.FindProperty("maxCount"); serMinCount.intValue = EditorGUILayout.IntField("Min Quantity", serMinCount.intValue); serMinCount.intValue = Mathf.Max(serMinCount.intValue, 1); serMinCount.intValue = Mathf.Min(serMinCount.intValue, serMaxCount.intValue); serMaxCount.intValue = EditorGUILayout.IntField("Max Quantity", serMaxCount.intValue); serMaxCount.intValue = Mathf.Min(serMaxCount.intValue, serDoorList.arraySize); serMaxCount.intValue = Mathf.Max(serMaxCount.intValue, serMinCount.intValue); EditorGUILayout.Space(); for (int i = 0; i < serDoorList.arraySize; i++) { SerializedProperty serDoor = serDoorList.GetArrayElementAtIndex(i); SerializedProperty serDoorPos = serDoor.FindPropertyRelative("Position"); //SerializedProperty serDoorSize = serDoor.FindPropertyRelative ("Size"); SerializedProperty serDoorName = serDoor.FindPropertyRelative("Name"); //serDoorSize.vector3Value = DoorDefinition.GlobalSize * Vector3.one; EditorGUILayout.BeginHorizontal(); GUIStyle labelStyle = EditorStyles.label; labelStyle.normal.textColor = (selectedIndex == i) ? Color.blue : Color.black; labelStyle.stretchWidth = true; string labelPrefix = serDoorPos.vector3Value.ToString(); if (doorDefinitions.doors.IndexOf(selectedDoor) == i) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(labelPrefix, labelStyle); serDoorName.stringValue = EditorGUILayout.TextField(serDoorName.stringValue); EditorGUILayout.EndHorizontal(); } else { if (GUILayout.Button(labelPrefix, labelStyle)) { selectedDoor = doorDefinitions.doors [i]; } EditorGUILayout.LabelField(serDoorName.stringValue); } labelStyle.normal.textColor = Color.black; if (GUILayout.Button("x", GUILayout.Width(20))) { serDoorList.DeleteArrayElementAtIndex(i); //In case the selected door has been deleted if (doorDefinitions.doors.IndexOf(selectedDoor) == i) { selectedDoor = null; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+ Add Door", buttonStyle)) { serDoorList.InsertArrayElementAtIndex(serDoorList.arraySize); InitializeNewDoor(serDoorList.GetArrayElementAtIndex(serDoorList.arraySize - 1)); } if (selectedDoor != null && GUILayout.Button("Clear Selection", buttonStyle)) { selectedDoor = null; } if (GUILayout.Button("<- Leave edit mode", buttonStyle)) { SceneUpdater.HideGizmos = false; } EditorGUILayout.EndHorizontal(); } serDoorDefinitions.ApplyModifiedProperties(); SceneUpdater.UpdateScene(); } }
void OnDisable() { SceneUpdater.HideGizmos = false; SceneUpdater.UpdateScene(); }
public override void DrawEditorGizmos() { Gizmos.color = Color.magenta; Gizmos.DrawWireCube(Vector3.up * (height / 2f), new Vector3(width, height, depth)); SceneUpdater.UpdateScene(); }