private void SetNodeStyleAndSize(SceneTextNode node, out GUIStyle style, out GUIStyle wrapStyle) { //Style select and height calculation int heightPadding = 62; style = nodeStyle; if (node.IsVariableText()) { style = variableNodeStyle; heightPadding += 40 * node.GetDescriptionCount(); } else { heightPadding += 20; } // if (node.GetHasOnEnterAction()) // { // heightPadding += 20; // heightPadding += 20 * node.GetOnEnterActionParameters().Count(); // } // if (node.GetHasOnExitAction()) // { // heightPadding += 20; // heightPadding += 20 * node.GetOnExitActionParameters().Count(); // } // if (node.GetHasConditionSelect()) // { // int conditionSize = node.GetConditionSize(); // for (int i = 0; i < conditionSize; i++) // { // heightPadding += 20; // if (node.GetFoldout(i)) // { // ConditionPredicate[] predicates = node.GetConditionPredicates(i).ToArray(); // for (int j = 0; j < predicates.Length; j++) // { // heightPadding += 42; // heightPadding += 20 * node.GetParameters(i, j).Count(); // } // } // else // { // heightPadding -= 1; // } // } // } wrapStyle = new GUIStyle(EditorStyles.textArea); wrapStyle.wordWrap = true; float nodeHeightCalc = wrapStyle.CalcHeight(new GUIContent(node.GetEditorText()), node.GetRect().width - style.padding.left - style.padding.right); node.SetNodeHeight(heightPadding + nodeHeightCalc); }
private void DrawNode(SceneTextNode node) { GUIStyle style, wrapStyle; SetNodeStyleAndSize(node, out style, out wrapStyle); GUILayout.BeginArea(node.GetRect(), style); // Create, Link, Destroy buttons GUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { creatingNode = node; } DrawLinkButtons(node); if (GUILayout.Button("x")) { nodeToDelete = node; } GUILayout.EndHorizontal(); // Toggle Is Player Speaking GUILayout.BeginHorizontal(); node.SetVariableText(EditorGUILayout.Toggle(node.IsVariableText())); EditorGUILayout.LabelField("Is Variable Description?"); GUILayout.EndHorizontal(); if (node.IsVariableText()) { node.SetDescriptionPredicate((TextDescriptionPredicate)EditorGUILayout.EnumPopup(node.GetDescriptionPredicate())); int descCount = node.GetDescriptionCount(); for (int i = 0; i < descCount; i++) { EditorGUILayout.FloatField(node.GetDescriptionLimit(i)); EditorGUILayout.TextField(node.GetDescriptionText(i)); } } else { // Dialogue Text node.SetText(EditorGUILayout.TextArea(node.GetEditorText(), wrapStyle)); } GUILayout.EndArea(); }