public bool RenderExposed(Action callback = null, bool ignoreButton = false) { bool returnValue = true; if (TiedObject == null) { EditorStyles.boldLabel.alignment = TextAnchor.MiddleLeft; GUILayout.Label("Name", EditorStyles.boldLabel); EditorStyles.boldLabel.alignment = TextAnchor.MiddleCenter; ButtonName = GUILayout.TextField(ButtonName, GUILayout.Width(ForgeNetworkingEditor.Instance.position.width - 50)); } else if (!ignoreButton) { Rect verticleButton = EditorGUILayout.BeginVertical("Button"); if (ForgeNetworkingEditor.ProVersion) { GUI.color = ButtonColor; } if (GUI.Button(verticleButton, GUIContent.none)) { if (callback != null) { callback(); return(false); } } EditorGUILayout.BeginHorizontal(); if (ForgeNetworkingEditor.ProVersion) { GUI.color = Color.white; } else { GUI.color = Color.black; } GUILayout.Label(ForgeNetworkingEditor.SideArrow); GUI.color = Color.white; GUILayout.FlexibleSpace(); GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel")); boldStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(ButtonName, boldStyle); GUILayout.FlexibleSpace(); if (ForgeNetworkingEditor.ProVersion) { GUI.color = Color.white; } else { GUI.color = Color.black; } GUILayout.Label(ForgeNetworkingEditor.SideArrowInverse); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); GUI.color = Color.white; } if (CanRenderFields) { EditorGUILayout.Space(); EditorStyles.boldLabel.alignment = TextAnchor.MiddleLeft; GUILayout.Label("Fields", EditorStyles.boldLabel); EditorStyles.boldLabel.alignment = TextAnchor.MiddleCenter; _classOrderList.DoLayoutList(); //Do we still need this? Rect addFieldBtn = EditorGUILayout.BeginVertical("Button", GUILayout.Width(75), GUILayout.Height(25)); GUI.color = Color.green; if (GUI.Button(addFieldBtn, GUIContent.none)) { ClassVariables.Add(new ForgeEditorField()); } EditorGUILayout.BeginHorizontal(); GUI.color = Color.white; GUILayout.FlexibleSpace(); GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel")); boldStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label("Add Field", boldStyle); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); // } if (CanRenderRPCS) { EditorGUILayout.Space(); EditorStyles.boldLabel.alignment = TextAnchor.MiddleLeft; GUILayout.Label("Remote Procedure Calls", EditorStyles.boldLabel); EditorStyles.boldLabel.alignment = TextAnchor.MiddleCenter; if (TiedObject != null) { EditorGUILayout.HelpBox("Re-arranging the RPC Arguments will require you to manually update your derriving code to use the new logic, please be aware of this.", MessageType.Warning); } _rpcOrderList.DoLayoutList(); Rect addRpcBtn = EditorGUILayout.BeginVertical("Button", GUILayout.Width(75), GUILayout.Height(25)); GUI.color = Color.green; if (GUI.Button(addRpcBtn, GUIContent.none)) { RPCVariables.Add(new ForgeEditorRPCField()); } //Do we still need this? EditorGUILayout.BeginHorizontal(); GUI.color = Color.white; GUILayout.FlexibleSpace(); GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel")); boldStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label("Add RPC", boldStyle); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); // } else { if (_tiedBehavior != null) { _tiedBehavior.RenderExposed(null, true); } } return(returnValue); }
/// <summary> /// This will render the create menu /// </summary> private void RenderCreateMenu() { if (_editorButtons == null) { Initialize(); return; //Editor is getting refreshed } if (ActiveButton == null) { return; } EditorGUILayout.Space(); _scrollView = GUILayout.BeginScrollView(_scrollView); bool canBack = ActiveButton.TiedObject == null; bool renderedSuccessful = ActiveButton.RenderExposed(_createUndo); GUILayout.EndScrollView(); if (!renderedSuccessful) { return; } bool generatedMonobehavior = EditorGUILayout.Toggle("Generate MonoBehavior", ActiveButton.BaseType != ForgeBaseClassType.NetworkBehavior); if (generatedMonobehavior) { ActiveButton.BaseType = ForgeBaseClassType.MonoBehavior; } else { ActiveButton.BaseType = ForgeBaseClassType.NetworkBehavior; } GUILayout.BeginHorizontal(); if (canBack) { Rect backBtn = EditorGUILayout.BeginVertical("Button", GUILayout.Width(100), GUILayout.Height(50)); GUI.color = Color.red; if (GUI.Button(backBtn, GUIContent.none)) { if (_createUndo != null) { _createUndo(); } } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUI.color = Color.white; GUILayout.FlexibleSpace(); GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel")); boldStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label("Back", boldStyle); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); Rect verticleButton = EditorGUILayout.BeginVertical("Button", GUILayout.Width(100), GUILayout.Height(50)); if (ProVersion) { GUI.color = TealBlue; } if (GUI.Button(verticleButton, GUIContent.none)) { if (ActiveButton.IsSetupCorrectly()) { _editorButtons.Add(ActiveButton); Compile(); ChangeMenu(ForgeEditorActiveMenu.Main); } else { Debug.LogError("Duplicate variable/rpc names found, please correct before compiling"); } } GUI.color = Color.white; EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.Label(SaveIcon); GUILayout.Label("Save & Compile", EditorStyles.boldLabel); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public bool RenderExposed(Action callback = null, bool ignoreButton = false) { bool returnValue = true; if (TiedObject == null) { EditorStyles.boldLabel.alignment = TextAnchor.MiddleLeft; GUILayout.Label("Name", EditorStyles.boldLabel); EditorStyles.boldLabel.alignment = TextAnchor.MiddleCenter; ButtonName = GUILayout.TextField(ButtonName, GUILayout.Width(ForgeNetworkingEditor.Instance.position.width - 50)); } else if (!ignoreButton) { Rect verticleButton = EditorGUILayout.BeginVertical("Button"); if (ForgeNetworkingEditor.ProVersion) { GUI.color = ButtonColor; } if (GUI.Button(verticleButton, GUIContent.none)) { if (callback != null) { callback(); return(false); } } EditorGUILayout.BeginHorizontal(); if (ForgeNetworkingEditor.ProVersion) { GUI.color = Color.white; } else { GUI.color = Color.black; } GUILayout.Label(ForgeNetworkingEditor.SideArrow); GUI.color = Color.white; GUILayout.FlexibleSpace(); GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel")); boldStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(ButtonName, boldStyle); GUILayout.FlexibleSpace(); if (ForgeNetworkingEditor.ProVersion) { GUI.color = Color.white; } else { GUI.color = Color.black; } GUILayout.Label(ForgeNetworkingEditor.SideArrowInverse); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); GUI.color = Color.white; } if (CanRenderFields) { EditorGUILayout.Space(); EditorStyles.boldLabel.alignment = TextAnchor.MiddleLeft; GUILayout.Label("Fields", EditorStyles.boldLabel); EditorStyles.boldLabel.alignment = TextAnchor.MiddleCenter; for (int i = 0; i < ClassVariables.Count; ++i) { if (ClassVariables[i].DELETED) { ClassVariables.RemoveAt(i); i--; continue; } ClassVariables[i].Render(); } Rect addFieldBtn = EditorGUILayout.BeginVertical("Button", GUILayout.Width(75), GUILayout.Height(25)); GUI.color = Color.green; if (GUI.Button(addFieldBtn, GUIContent.none)) { ClassVariables.Add(new ForgeEditorField()); } EditorGUILayout.BeginHorizontal(); GUI.color = Color.white; GUILayout.FlexibleSpace(); GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel")); boldStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label("Add Field", boldStyle); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } if (CanRenderRPCS) { EditorGUILayout.Space(); EditorStyles.boldLabel.alignment = TextAnchor.MiddleLeft; GUILayout.Label("Remote Procedure Calls", EditorStyles.boldLabel); EditorStyles.boldLabel.alignment = TextAnchor.MiddleCenter; for (int i = 0; i < RPCVariables.Count; ++i) { if (RPCVariables[i].DELETED) { RPCVariables.RemoveAt(i); i--; continue; } RPCVariables[i].Render(); } Rect addRpcBtn = EditorGUILayout.BeginVertical("Button", GUILayout.Width(75), GUILayout.Height(25)); GUI.color = Color.green; if (GUI.Button(addRpcBtn, GUIContent.none)) { RPCVariables.Add(new ForgeEditorRPCField()); } EditorGUILayout.BeginHorizontal(); GUI.color = Color.white; GUILayout.FlexibleSpace(); GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel")); boldStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label("Add RPC", boldStyle); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } else { if (_tiedBehavior != null) { _tiedBehavior.RenderExposed(null, true); } } return(returnValue); }