public override void OnInspectorGUI() { serializedObject.Update(); GUILayout.Space(10); #region Inspector GUILayout.BeginVertical("Easy Build System - Android Builder Behaviour", "window", GUILayout.Height(10)); GUILayout.BeginVertical("box"); GUI.color = MainEditor.GetEditorColor; GUILayout.BeginHorizontal(); GUILayout.Label("Android Builder Behaviour Settings", EditorStyles.largeLabel); #region Builder Behaviour Settings if (GUILayout.Button(DefaultInspector ? "Advanced Inspector" : "Default Inspector", GUILayout.Width(130))) { DefaultInspector = !DefaultInspector; } if (GUILayout.Button(AllIsOpen ? "Fold In" : "Fold Out", GUILayout.Width(80))) { BaseFoldout = !BaseFoldout; ModesFoldout = !ModesFoldout; PreviewFoldout = !PreviewFoldout; InputsFoldout = !InputsFoldout; AudioFoldout = !AudioFoldout; AddonsFoldout = !AddonsFoldout; AllIsOpen = !AllIsOpen; } if (GUILayout.Button(Help ? "Hide Help" : "Show Help", GUILayout.Width(100))) { Help = !Help; } GUI.color = Color.white; GUILayout.EndHorizontal(); if (Help) { EditorGUILayout.HelpBox("This component contains all the behaviours whose can be executed by the player during the runtime on mobile.\n" + "It require the Build Manager prefab in the scene with an Parts Collection, otherwise it will be useless.\n" + "Note : Also check that this component is only present once in your scene, otherwise it can cause problems.", MessageType.Info); GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Open Documentation Link")) { Application.OpenURL(Constants.DOCS_LINK); } GUI.color = Color.white; } if (DefaultInspector) { DrawDefaultInspector(); GUILayout.EndVertical(); GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); return; } GUI.enabled = false; EditorGUILayout.ObjectField("Script", target, typeof(BuilderBehaviour), true); GUI.enabled = true; GUILayout.BeginHorizontal(); GUILayout.Space(13); BaseFoldout = EditorGUILayout.Foldout(BaseFoldout, "Base Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (BaseFoldout) { EditorGUILayout.PropertyField(serializedObject.FindProperty("CameraType"), new GUIContent("Camera Placement Type :", "This allows to define the raycast origin type.\n" + "First Person : The raycast origin come from camera center.\n" + "Top Down : The raycast origin come from mouse position.\n" + "Third Person : The raycast origin come from reference Transform Point.")); if (((RayType)serializedObject.FindProperty("CameraType").enumValueIndex) == RayType.TopDown) { EditorGUILayout.PropertyField(serializedObject.FindProperty("RaycastAnchorTransform"), new GUIContent("Top Down Anchor Transform :", "This allows to define the origin transform where the ray will be sent (Optional).")); EditorGUILayout.PropertyField(serializedObject.FindProperty("SnapThreshold"), new GUIContent("Top Down Snap Threshold :", "This allows to define the threshold distance on which the preview can will be moved in allowed status.")); } else if (((RayType)serializedObject.FindProperty("CameraType").enumValueIndex) == RayType.ThirdPerson) { EditorGUILayout.PropertyField(serializedObject.FindProperty("RaycastOriginTransform"), new GUIContent("Third Person Origin Transform :", "This allows to define the origin transform where the ray will be sent.")); } EditorGUILayout.PropertyField(serializedObject.FindProperty("ActionDistance"), new GUIContent("Raycast Placement Distance :", "This allows to define the maximum distance on which the preview can will be moved in allowed status.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("OutOfRangeDistance"), new GUIContent("Raycast Out Of Range Distance :", "This allows to define the maximum out of range distance on which the preview can will be moved in denied status. (0 = Use only Placement Distance)")); EditorGUILayout.PropertyField(serializedObject.FindProperty("RayDetection"), new GUIContent("Raycast Detection Type :", "This allows to define the accuracy raycast type.\nIt is advisable to use the following types :\nLine if you've sockets with the type (Attachment).\nOverlap if you've sockets with the type (Point).")); if (serializedObject.FindProperty("RayDetection").enumValueIndex == (int)DetectionType.Overlap) { EditorGUILayout.PropertyField(serializedObject.FindProperty("OverlapAngles"), new GUIContent("Raycast Overlap Angles :", "This allows to define the maximum angles to detect the sockets.")); } EditorGUILayout.PropertyField(serializedObject.FindProperty("RaycastOffset"), new GUIContent("Raycast Forward Offset :", "This allows to define the raycast offset on axis (Z).")); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Builder Behaviour Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Builder Modes Settings", EditorStyles.largeLabel); #region Builder Modes Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); ModesFoldout = EditorGUILayout.Foldout(ModesFoldout, "Modes Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (ModesFoldout) { EditorGUILayout.PropertyField(serializedObject.FindProperty("UsePlacementMode"), new GUIContent("Use Placement Mode :", "This allows to allow the placement mode.")); if (serializedObject.FindProperty("UsePlacementMode").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("ResetModeAfterPlacement"), new GUIContent("Reset Mode After Placement Action :", "This allows to reset the mode to (None) after the placement.")); } EditorGUILayout.PropertyField(serializedObject.FindProperty("UseDestructionMode"), new GUIContent("Use Destruction Mode :", "This allows to allow the destruction mode.")); if (serializedObject.FindProperty("UseDestructionMode").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("ResetModeAfterDestruction"), new GUIContent("Reset Mode After Destruction Action :", "This allows to reset the mode to (None) after the destruction.")); } EditorGUILayout.PropertyField(serializedObject.FindProperty("UseEditionMode"), new GUIContent("Use Edition Mode :", "This allows to allow the edition mode.")); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Builder Modes Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Builder Preview Settings", EditorStyles.largeLabel); #region Builder Preview Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); PreviewFoldout = EditorGUILayout.Foldout(PreviewFoldout, "Preview Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (PreviewFoldout) { EditorGUILayout.PropertyField(serializedObject.FindProperty("UsePreviewCamera"), new GUIContent("Use Through Preview :", "This allows to use the preview camera, this will allows to see through the mesh like terrain details.")); if (serializedObject.FindProperty("UsePreviewCamera").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewCamera"), new GUIContent("Through Preview Camera :", "This allows to define the preview camera will be used.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewLayer"), new GUIContent("Through Preview Layer :", "This allows to define the preview layer that the camera can see."), true); } EditorGUILayout.PropertyField(serializedObject.FindProperty("LockRotation"), new GUIContent("Lock Preview Rotation :", "This allows to make that the preview look the camera rotation.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewMovementOnlyAllowed"), new GUIContent("Preview Movement Only Possible :", "This allows to move the preview only if has not collider.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewMovementType"), new GUIContent("Preview Movement Type :", "This allows to define the preview movement type.")); if ((MovementType)serializedObject.FindProperty("PreviewMovementType").enumValueIndex == MovementType.Smooth) { EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewSmoothTime"), new GUIContent("Preview Movement Smooth Time :", "This allows to define the smooth time movement.")); } if ((MovementType)serializedObject.FindProperty("PreviewMovementType").enumValueIndex == MovementType.Grid) { EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewGridSize"), new GUIContent("Preview Grid Size :", "This allows to define the grid size on which the preview will be moved.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewGridOffset"), new GUIContent("Preview Grid Offset :", "This allows to define the grid offset for the preview position.")); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Builder Preview Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Builder Audio Settings", EditorStyles.largeLabel); #region Builder Audio Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); AudioFoldout = EditorGUILayout.Foldout(AudioFoldout, "Audio Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); GUI.color = Color.white; if (AudioFoldout) { EditorGUILayout.HelpBox("To use the placements and destructions sounds, add below your Audio Source component also that the clips.\n" + "If the Audio Source field is empty, no clips will be played during the runtime.", MessageType.Warning); EditorGUILayout.PropertyField(serializedObject.FindProperty("Source"), new GUIContent("Audio Source :", "This source is the source on which the sounds will be played.")); GUILayout.BeginHorizontal(); GUILayout.Space(13); EditorGUILayout.PropertyField(serializedObject.FindProperty("PlacementClips"), new GUIContent("Placement Audio Sound(s) :", "Placement clips at play when a preview is placed (Played randomly)."), true); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); EditorGUILayout.PropertyField(serializedObject.FindProperty("DestructionClips"), new GUIContent("Destructions Audio Sound(s) :", "Destruction clips at play when a part is destroyed (Played randomly."), true); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Builder Audio Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Builder Add-Ons Settings", EditorStyles.largeLabel); #region Builder Add-Ons Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); AddonsFoldout = EditorGUILayout.Foldout(AddonsFoldout, "Add-Ons Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (AddonsFoldout) { MainEditor.DrawAddons(Target, AddOnTarget.BuilderBehaviour); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Builder Add-Ons Settings GUILayout.EndVertical(); GUILayout.EndVertical(); #endregion Inspector serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); }
public override void OnInspectorGUI() { serializedObject.Update(); GUILayout.Space(10); #region Inspector GUILayout.BeginVertical("Easy Build System - Socket Behaviour", "window", GUILayout.MaxHeight(10)); GUILayout.BeginVertical("box"); GUI.color = MainEditor.GetEditorColor; GUILayout.BeginHorizontal(); GUILayout.Label("Socket Behaviour Settings", EditorStyles.largeLabel); #region Socket Behaviour Settings GUILayout.FlexibleSpace(); if (GUILayout.Button(DefaultInspector ? "Advanced Inspector" : "Default Inspector", GUILayout.Width(130))) { DefaultInspector = !DefaultInspector; } if (GUILayout.Button(AllIsOpen ? "Fold In" : "Fold Out", GUILayout.Width(80))) { BaseFoldout = !BaseFoldout; OffsetsFoldout = !OffsetsFoldout; AddonsFoldout = !AddonsFoldout; AllIsOpen = !AllIsOpen; } if (GUILayout.Button(Help ? "Hide Help" : "Show Help", GUILayout.Width(100))) { Help = !Help; } GUI.color = Color.white; GUILayout.EndHorizontal(); if (Help) { EditorGUILayout.HelpBox("This component allows to snap with the Builder Behaviour the Parts Behaviour according the offset settings during the runtime.\n" + "Sockets can cause problems if they are misconfigured, If it disable off unnaturally, please change their offset or radius.", MessageType.Info); GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Open Documentation Link")) { Application.OpenURL(Constants.DOCS_LINK); } GUI.color = Color.white; } if (DefaultInspector) { DrawDefaultInspector(); GUILayout.EndVertical(); GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); return; } GUI.enabled = false; EditorGUILayout.ObjectField("Script", target, typeof(SocketBehaviour), true); GUI.enabled = true; GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); BaseFoldout = EditorGUILayout.Foldout(BaseFoldout, "Base Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (BaseFoldout) { EditorGUILayout.PropertyField(serializedObject.FindProperty("Type"), new GUIContent("Socket Type :", "This allows to define the socket type.")); if ((SocketType)serializedObject.FindProperty("Type").enumValueIndex == SocketType.Socket) { EditorGUILayout.PropertyField(serializedObject.FindProperty("Radius"), new GUIContent("Socket Radius :", "This allows to define the socket radius point.\nYou can decrease the socket radius to improve the precision during the detection.")); } else { EditorGUILayout.PropertyField(serializedObject.FindProperty("AttachmentBounds"), new GUIContent("Socket Attachment Bounds :", "This allows to define the attachment bounds.")); } EditorGUILayout.PropertyField(serializedObject.FindProperty("DisableOnGroundContact"), new GUIContent("Disable On Terrain/Surface Contact :", "This allows to define if the socket will be disable if she's entering in collision with the terrain or the surface.")); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Socket Behaviour Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Socket Offset(s) Settings", EditorStyles.largeLabel); #region Socket Offsets Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); OffsetsFoldout = EditorGUILayout.Foldout(OffsetsFoldout, "Offsets Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (OffsetsFoldout) { GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (Target.PartOffsets.Count == 0) { GUILayout.BeginHorizontal("box"); GUI.color = new Color(1.5f, 1.5f, 0f); GUILayout.Label("The list does not contains of offset part(s), No part(s) will may be snap on it."); GUI.color = Color.white; GUILayout.EndHorizontal(); } else { int Index = 0; foreach (PartOffset Offset in Target.PartOffsets) { if (Offset == null || Offset.Part == null) { Target.PartOffsets.Remove(Offset); EditorUtility.SetDirty(target); return; } GUILayout.BeginHorizontal("box"); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("(ID:" + Offset.Part.Id + ") " + Offset.Part.Name, EditorStyles.largeLabel); if (PreviewPart != null && int.Parse(PreviewPart.name) == Offset.Part.Id) { GUI.color = new Color(1.5f, 1.5f, 0f); if (GUILayout.Button("Cancel Preview", GUILayout.Width(100))) { ClearPreview(); } } else { GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Preview Part", GUILayout.Width(100))) { ClearPreview(); CurrentOffset = Offset; CreatePreview(Offset); } } GUI.color = Color.white; GUI.color = new Color(1.5f, 0, 0); if (GUILayout.Button("Remove", GUILayout.Width(80))) { Target.PartOffsets.Remove(Offset); ClearPreview(); return; } GUI.color = Color.white; GUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUI.BeginChangeCheck(); Offset.Position = EditorGUILayout.Vector3Field(new GUIContent("Offset Position : ", "This allows to set the position of part that will snapped on this socket."), Offset.Position); Offset.Rotation = EditorGUILayout.Vector3Field(new GUIContent("Offset Rotation : ", "This allows to set the rotation of part that will snapped on this socket."), Offset.Rotation); Offset.UseCustomScale = EditorGUILayout.Toggle(new GUIContent("Offset Use Custom Scale : ", "This allows to define whether the part to be snap to this socket will have a specific scale, otherwise it will be the scale only of the part."), Offset.UseCustomScale); if (Offset.UseCustomScale) { Offset.Scale = EditorGUILayout.Vector3Field(new GUIContent("Offset Scale : ", "This allows to define the specific scale of the part that will be snapped on this socket."), Offset.Scale); } if (EditorGUI.EndChangeCheck()) { if (PreviewPart != null) { if (PreviewPart.name == Offset.Part.Id.ToString()) { PreviewPart.transform.position = Target.transform.TransformPoint(Offset.Position); PreviewPart.transform.rotation = Quaternion.Euler(Offset.Rotation); PreviewPart.transform.localScale = Offset.UseCustomScale ? Offset.Scale : (Target.transform.parent != null ? Target.transform.parent.localScale : Target.transform.localScale); } EditorUtility.SetDirty(target); } } GUI.color = MainEditor.GetEditorColor; if (!ShowPartOffsetEditor || CurrentOffset != Offset) { if (GUILayout.Button("Edit Offset Part")) { SceneHelper.Focus(target, DrawCameraMode.Textured); if (PreviewPart != null) { DestroyImmediate(PreviewPart); } CurrentOffsetIndex = Index; CurrentOffset = Offset; ShowPartOffsetEditor = true; } } else if (CurrentOffset == Offset) { GUI.color = Color.white; EditorGUILayout.HelpBox("The position, rotation as well as the scale of the current part displayed, will be exactly the same in runtime.", MessageType.Info); GUI.color = new Color(0f, 1.5f, 1.5f); if (GUILayout.Button("Close")) { SceneHelper.UnFocus(); ShowPartOffsetEditor = false; Target.PartOffsets[CurrentOffsetIndex] = CurrentOffset; EditorUtility.SetDirty(target); Debug.Log("<b><color=cyan>[Easy Build System]</color></b> : The offsets changes were saved."); } } GUI.color = Color.white; GUILayout.Space(2); GUILayout.EndVertical(); GUILayout.EndHorizontal(); Index++; } } try { GUILayout.BeginVertical("box"); GUILayout.BeginHorizontal(); PrefabField = (PartBehaviour)EditorGUILayout.ObjectField(new GUIContent("Base Part :", "Part at add to the list for the snap according to the offset on this socket in runtime."), PrefabField, typeof(PartBehaviour), false); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); GUI.enabled = PrefabField != null; GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Add New Offset Part")) { if (PrefabField == null) { Debug.LogError("<b><color=cyan>[Easy Build System]</color></b> : Empty field."); return; } if (Target.PartOffsets.Find(entry => entry.Part.Name == PrefabField.Name) == null) { ClearPreview(); PartOffset Offset = new PartOffset(PrefabField); Target.PartOffsets.Add(Offset); CurrentOffset = Offset; CreatePreview(Offset); PrefabField = null; Repaint(); } else { Debug.LogError("<b><color=cyan>[Easy Build System]</color></b> : This part already exists in the collection."); } } GUI.color = Color.white; GUI.enabled = true; GUI.color = new Color(1.5f, 1.5f, 0f); if (GUILayout.Button("Clear All Offset Part(s) List")) { if (EditorUtility.DisplayDialog("Easy Build System - Information", "Do you want remove all the offset part(s) from the collection ?", "Ok", "Cancel")) { Target.PartOffsets.Clear(); Debug.Log("<b><color=cyan>[Easy Build System]</color></b> : The collection has been clear !."); } } GUI.color = Color.white; GUILayout.EndVertical(); GUILayout.Space(3); GUILayout.EndVertical(); } catch { } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Socket Offsets Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Socket Utilities Settings", EditorStyles.largeLabel); #region Socket Utilities Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); UtilitiesFoldout = EditorGUILayout.Foldout(UtilitiesFoldout, "Utilities Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (UtilitiesFoldout) { GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Duplicate Socket (Inverse)")) { GameObject Duplicate = Instantiate(Target.gameObject, Target.transform.parent); Duplicate.name = Target.transform.name; Vector3 Inverse = new Vector3(-Target.transform.localPosition.x, Target.transform.localPosition.y, -Target.transform.localPosition.z); Duplicate.transform.localPosition = Inverse; Selection.activeGameObject = Duplicate; } GUI.color = Color.white; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Socket Utilities Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Socket Add-Ons Settings", EditorStyles.largeLabel); #region Socket Add-Ons Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); AddonsFoldout = EditorGUILayout.Foldout(AddonsFoldout, "Add-Ons Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (AddonsFoldout) { MainEditor.DrawAddons(Target, AddOnTarget.SocketBehaviour); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Socket Add-Ons Settings GUILayout.EndVertical(); GUILayout.EndVertical(); #endregion Inspector GUILayout.Space(10); serializedObject.ApplyModifiedProperties(); if (CurrentOffset != null) { if (PreviewPart != null) { PreviewPart.transform.position = Target.transform.TransformPoint(CurrentOffset.Position); PreviewPart.transform.rotation = Target.transform.rotation * Quaternion.Euler(CurrentOffset.Rotation); } } if (GUI.changed) { Target.PartOffsets = Target.PartOffsets.ToList().OrderBy(item => item.Part.Id).ToList(); } }
public override void OnInspectorGUI() { serializedObject.Update(); GUILayout.Space(10); #region Inspector GUILayout.BeginVertical("Easy Build System - Area Behaviour", "window", GUILayout.Height(10)); GUILayout.BeginVertical("box"); GUI.color = MainEditor.GetEditorColor; GUILayout.BeginHorizontal(); GUILayout.Label("Area Behaviour Settings", EditorStyles.largeLabel); #region Area Behaviour Settings GUILayout.FlexibleSpace(); if (GUILayout.Button(DefaultInspector ? "Advanced Inspector" : "Default Inspector", GUILayout.Width(130))) { DefaultInspector = !DefaultInspector; } if (GUILayout.Button(AllIsOpen ? "Fold In" : "Fold Out", GUILayout.Width(80))) { BaseFoldout = !BaseFoldout; AddonsFoldout = !AddonsFoldout; AllIsOpen = !AllIsOpen; } if (GUILayout.Button(Help ? "Hide Help" : "Show Help", GUILayout.Width(100))) { Help = !Help; } GUI.color = Color.white; GUILayout.EndHorizontal(); if (Help) { EditorGUILayout.HelpBox("This component allow/deny the placement or the destruction according the radius during the runtime.\n" + "It can also attached as childs to avoid the close placement.", MessageType.Info); GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Open Documentation Link")) { Application.OpenURL(Constants.DOCS_LINK); } GUI.color = Color.white; } if (DefaultInspector) { DrawDefaultInspector(); GUILayout.EndVertical(); GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); return; } GUI.enabled = false; EditorGUILayout.ObjectField("Script", target, typeof(AreaBehaviour), true); GUI.enabled = true; GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); BaseFoldout = EditorGUILayout.Foldout(BaseFoldout, "Base Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (BaseFoldout) { EditorGUILayout.PropertyField(serializedObject.FindProperty("Radius"), new GUIContent("Area Radius :", "This allows to define the radius of area.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("AllowPlacement"), new GUIContent("Allow Placement In Area :", "This allows the placement in the area of part(s) from the collection below.")); if (serializedObject.FindProperty("AllowPlacement").boolValue) { GUILayout.BeginHorizontal(); GUILayout.Space(13); EditorGUILayout.PropertyField(serializedObject.FindProperty("AllowPartPlacement"), new GUIContent("Allow Part(s) In Area :", "This allows to define the part(s) that can be placed."), true); GUILayout.EndHorizontal(); } EditorGUILayout.PropertyField(serializedObject.FindProperty("AllowDestruction"), new GUIContent("Allow Destruction In Area :", "This allows the destruction of all the part(s) in the area.")); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Area Behaviour Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Area Add-On(s) Settings", EditorStyles.largeLabel); #region Area Add-Ons Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); AddonsFoldout = EditorGUILayout.Foldout(AddonsFoldout, "Add-Ons Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (AddonsFoldout) { MainEditor.DrawAddons(Target, AddOnTarget.AreaBehaviour); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Area Add-Ons Settings GUILayout.EndVertical(); GUILayout.EndVertical(); #endregion Inspector serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); }
public override void OnInspectorGUI() { serializedObject.Update(); GUILayout.Space(10); #region Inspector GUILayout.BeginVertical("Easy Build System - Group Behaviour", "window", GUILayout.Height(10)); GUILayout.BeginVertical("box"); GUI.color = MainEditor.GetEditorColor; GUILayout.BeginHorizontal(); GUILayout.Label("Group Behaviour Settings", EditorStyles.largeLabel); #region Group Behaviour Settings GUILayout.FlexibleSpace(); if (GUILayout.Button(DefaultInspector ? "Advanced Inspector" : "Default Inspector", GUILayout.Width(130))) { DefaultInspector = !DefaultInspector; } if (GUILayout.Button(AllIsOpen ? "Fold In" : "Fold Out", GUILayout.Width(80))) { AddonsFoldout = !AddonsFoldout; AllIsOpen = !AllIsOpen; } if (GUILayout.Button(Help ? "Hide Help" : "Show Help", GUILayout.Width(100))) { Help = !Help; } GUI.color = Color.white; GUILayout.EndHorizontal(); if (Help) { EditorGUILayout.HelpBox("This component allows to save and load of Group Behaviour which contains of Parts Behaviour during the edit/runtime.\n" + "The data below can be shared and loaded if the Build Manager use the same Id's in the Parts Collection.", MessageType.Info); GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Open Documentation Link")) { Application.OpenURL(Constants.DOCS_LINK); } GUI.color = Color.white; } if (DefaultInspector) { DrawDefaultInspector(); GUILayout.EndVertical(); GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); return; } GUI.enabled = false; EditorGUILayout.ObjectField("Script", target, typeof(AreaBehaviour), true); GUI.enabled = true; GUI.color = Color.white; if (Application.isPlaying) { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Save As Blueprint...")) { BlueprintData Data = ScriptableObjectExtension.CreateAsset <BlueprintData>("New Empty Blueprint"); Data.name = Target.name; Data.Model = Target.GetModel(); Data.Data = Target.GetModel().EncodeToStr(); Debug.Log("<b><color=cyan>[Easy Build System]</color></b> : The blueprint model has been saved."); } if (GUILayout.Button("Destroy Group")) { Destroy(Target.gameObject); Debug.Log("<b><color=cyan>[Easy Build System]</color></b> : The group has been destroyed."); } GUI.enabled = true; GUI.color = Color.white; GUILayout.EndVertical(); GUILayout.EndHorizontal(); } #endregion Group Behaviour Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Group Add-On(s) Settings", EditorStyles.largeLabel); #region Group Add-Ons Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); AddonsFoldout = EditorGUILayout.Foldout(AddonsFoldout, "Add-Ons Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (AddonsFoldout) { MainEditor.DrawAddons(Target, AddOnTarget.GroupBehaviour); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Group Add-Ons Settings GUILayout.EndVertical(); GUILayout.EndVertical(); #endregion Inspector serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); }
public override void OnInspectorGUI() { serializedObject.Update(); GUILayout.Space(10); #region Inspector GUILayout.BeginVertical("Easy Build System - Build Manager", "window", GUILayout.Height(10)); GUILayout.BeginVertical("box"); GUI.color = MainEditor.GetEditorColor; GUILayout.BeginHorizontal(); GUILayout.Label("Build Manager Settings", EditorStyles.largeLabel); #region Build Manager Settings if (GUILayout.Button(DefaultInspector ? "Advanced Inspector" : "Default Inspector", GUILayout.Width(130))) { DefaultInspector = !DefaultInspector; } if (GUILayout.Button(AllIsOpen ? "Fold In" : "Fold Out", GUILayout.Width(80))) { BaseFoldout = !BaseFoldout; PreviewFoldout = !PreviewFoldout; AddonsFoldout = !AddonsFoldout; AllIsOpen = !AllIsOpen; } if (GUILayout.Button(Help ? "Hide Help" : "Show Help", GUILayout.Width(100))) { Help = !Help; } GUI.color = Color.white; GUILayout.EndHorizontal(); if (Help) { EditorGUILayout.HelpBox("This component is fundamental to the proper functioning of the system.\n" + "It allows to manage all the actions that can be performed on the scene during the runtime.\n" + "This component must be only once in each scene where you want to use the system.", MessageType.Info); GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Open Documentation Link")) { Application.OpenURL(Constants.DOCS_LINK); } GUI.color = Color.white; } if (DefaultInspector) { DrawDefaultInspector(); GUILayout.EndVertical(); GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); return; } GUI.enabled = false; EditorGUILayout.ObjectField("Script", target, typeof(BuilderBehaviour), true); GUI.enabled = true; GUILayout.BeginHorizontal(); GUILayout.Space(13); BaseFoldout = EditorGUILayout.Foldout(BaseFoldout, "Base Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (BaseFoldout) { EditorGUILayout.PropertyField(serializedObject.FindProperty("BuildingSupport"), new GUIContent("Build Surface :", "This allows to define the type of support to be able to place all the parts of type (Foundation).\n\n" + "(All) Allow only the placement on all the gameObject(s).\n\n" + "(Terrain) Allow only the placement on Unity Terrain.\n\n" + "(Voxeland) Allow only the placement on Voxeland Terrain.\n\n" + "(Surface) Allow only the placement on the colliders with the component Surface Collider.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("FreeLayers"), new GUIContent("Build Free Layers :", "This allows to define the layer(s) on which the preview will be placed and moved.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("SocketLayers"), new GUIContent("Build Socket Layers :", "This allows to define the layer(s) that will be detected to snap the preview.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("PartsCollection"), new GUIContent("Collection To Load :", "This allows define all the parts selectable in runtime.")); if (serializedObject.FindProperty("UsePhysics").boolValue) { EditorGUILayout.HelpBox("The physics will be taken into account at the startup of the scene during the runtime.\nCheck that your parts uses also the physics.", MessageType.Info); } EditorGUILayout.PropertyField(serializedObject.FindProperty("UsePhysics"), new GUIContent("Use Conditional Physics :", "This allows define if the system take into account the physics of parts.")); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Build Manager Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Build Manager Preview Settings", EditorStyles.largeLabel); #region Preview Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); PreviewFoldout = EditorGUILayout.Foldout(PreviewFoldout, "Preview Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (PreviewFoldout) { EditorGUILayout.PropertyField(serializedObject.FindProperty("UseDefaultPreviewMaterial"), new GUIContent("Use Custom Material :", "This allows to use a custom material for the preview.")); if (serializedObject.FindProperty("UseDefaultPreviewMaterial").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("CustomPreviewMaterial"), new GUIContent("Preview Custom Material :", "Define here the custom material.")); } EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewAllowedColor"), new GUIContent("Preview Allowed Color :", "This allows to show the allowed color when the preview can be placed.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewDeniedColor"), new GUIContent("Preview Denied Color :", "This allows to show the denied color when the preview can't be placed.")); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Preview Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Build Manager Add-Ons Settings", EditorStyles.largeLabel); #region Build Manager Add-Ons Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); AddonsFoldout = EditorGUILayout.Foldout(AddonsFoldout, "Add-Ons Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (AddonsFoldout) { MainEditor.DrawAddons(Target, AddOnTarget.BuildManager); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Build Manager Add-Ons Settings GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Open Easy Build System - Main Editor")) { MainEditor.Init(); } GUI.color = Color.white; GUILayout.EndVertical(); GUILayout.EndVertical(); #endregion Inspector serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); }
public override void OnInspectorGUI() { serializedObject.Update(); GUILayout.Space(10); #region Inspector GUILayout.BeginVertical("Easy Build System - Build Storage", "window", GUILayout.Height(10)); GUILayout.BeginVertical("box"); GUI.color = MainEditor.GetEditorColor; GUILayout.BeginHorizontal(); GUILayout.Label("Build Storage Settings", EditorStyles.largeLabel); #region Build Storage Settings if (GUILayout.Button(DefaultInspector ? "Advanced Inspector" : "Default Inspector", GUILayout.Width(130))) { DefaultInspector = !DefaultInspector; } if (GUILayout.Button(AllIsOpen ? "Fold In" : "Fold Out", GUILayout.Width(80))) { BaseFoldout = !BaseFoldout; AddonsFoldout = !AddonsFoldout; AllIsOpen = !AllIsOpen; } if (GUILayout.Button(Help ? "Hide Help" : "Show Help", GUILayout.Width(100))) { Help = !Help; } GUI.color = Color.white; GUILayout.EndHorizontal(); if (Help) { EditorGUILayout.HelpBox("This component allows to save and load all the Parts Behaviour of the scene before/after the runtime.\n" + "Note : The larger the number of parts saved in the file, please select Json in the serializer type field.", MessageType.Info); GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Open Documentation Link")) { Application.OpenURL(Constants.DOCS_LINK); } GUI.color = Color.white; } if (DefaultInspector) { DrawDefaultInspector(); GUILayout.EndVertical(); GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); return; } GUI.enabled = false; EditorGUILayout.ObjectField("Script", target, typeof(BuilderBehaviour), true); GUI.enabled = true; GUILayout.BeginHorizontal(); GUILayout.Space(13); BaseFoldout = EditorGUILayout.Foldout(BaseFoldout, "Base Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (BaseFoldout) { EditorGUILayout.PropertyField(serializedObject.FindProperty("StorageType"), new GUIContent("Storage Type :", "This allows to save/load for Desktop or Android.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("StorageSerializer"), new GUIContent("Storage Serializer Type :", "This allows to define the serializer type.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("AutoSave"), new GUIContent("Use Auto Save :", "This allows to enable auto save.")); if (serializedObject.FindProperty("AutoSave").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("AutoSaveInterval"), new GUIContent("Auto Save Interval (ms) :", "This allows to define the auto save interval.")); } EditorGUILayout.PropertyField(serializedObject.FindProperty("SavePrefabs"), new GUIContent("Save All Part Behaviour :", "This allows to save all the prefabs after have exited the scene.")); EditorGUILayout.PropertyField(serializedObject.FindProperty("LoadPrefabs"), new GUIContent("Load All Part Behaviour :", "This allows to save all the prefabs at startup of the scene.")); if (serializedObject.FindProperty("StorageType").enumValueIndex == 0) { EditorGUI.BeginChangeCheck(); EditorGUILayout.HelpBox("Define here the complete path with the name & extension.\n" + @"Example For Windows : C:\Users\My Dekstop\Desktop\MyFile.dat", MessageType.Info); EditorGUILayout.PropertyField(serializedObject.FindProperty("StorageOutputFile"), new GUIContent("Storage Output Path :", "Output path to save and load the file.")); EditorGUI.EndChangeCheck(); if (GUI.changed) { EditorUtility.SetDirty(target); } } GUI.color = MainEditor.GetEditorColor; if (GUILayout.Button("Load Storage File In Editor Scene ...")) { if (EditorUtility.DisplayDialog("Easy Build System - Information", "(Only Large File) Note :\nYour scene will be saved, to avoid the loss of data in case of a crash of the editor.", "Load", "Cancel")) { EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); LoadPath = EditorUtility.OpenFilePanel("Load Ebs Storage File :", "", "*.*"); if (LoadPath != string.Empty) { Target.LoadInEditor(LoadPath); } } } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Build Storage Settings GUI.color = MainEditor.GetEditorColor; GUILayout.Label("Build Storage Add-Ons Settings", EditorStyles.largeLabel); #region Socket Add-Ons Settings GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.Space(13); AddonsFoldout = EditorGUILayout.Foldout(AddonsFoldout, "Add-Ons Section Settings"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(13); GUILayout.BeginVertical(); if (AddonsFoldout) { MainEditor.DrawAddons(Target, AddOnTarget.StorageBehaviour); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Socket Add-Ons Settings GUILayout.EndVertical(); GUILayout.EndVertical(); #endregion Inspector serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); }