protected override void OnNodeInspectorGUI() { if (outConnections.Count == 0) { GUILayout.Label("Make some connections first"); return; } CalcTotal(); for (int i = 0; i < childWeights.Count; i++) { GUILayout.BeginHorizontal(); childWeights[i] = (BBFloat)EditorUtils.BBVariableField("Weight", childWeights[i]); GUILayout.Label(Mathf.Round((childWeights[i].value / total) * 100) + "%", GUILayout.Width(30)); GUILayout.EndHorizontal(); } GUILayout.Space(5); GUILayout.BeginHorizontal(); failChance = (BBFloat)EditorUtils.BBVariableField("Direct Failure Chance", failChance); GUILayout.Label(Mathf.Round((failChance.value / total) * 100) + "%", GUILayout.Width(30)); GUILayout.EndHorizontal(); }
/////// protected override void OnTaskInspectorGUI() { EditorGUILayout.HelpBox(agent == null? "Agent is unknown.\nYou can select a type and a method" : "Agent is known.\nMethod selection will be done from existing components", MessageType.Info); if (!Application.isPlaying && agent == null && GUILayout.Button("Alter Type")) { System.Action <System.Type> TypeSelected = delegate(System.Type t){ var newTypeName = t.AssemblyQualifiedName; if (scriptName != newTypeName) { scriptName = newTypeName; methodName = null; } }; EditorUtils.ShowConfiguredTypeSelectionMenu(typeof(Component), TypeSelected); } if (!Application.isPlaying && GUILayout.Button("Select Property")) { System.Action <MethodInfo> MethodSelected = delegate(MethodInfo method){ if (!typeof(Component).IsAssignableFrom(method.DeclaringType) && !method.DeclaringType.IsInterface) { return; } scriptName = method.DeclaringType.AssemblyQualifiedName; methodName = method.Name; setValue.selectedType = method.GetParameters()[0].ParameterType; }; if (agent != null) { EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, new List <System.Type> { typeof(void) }, setValue.availableTypes, MethodSelected, 1, true); } else { var menu = EditorUtils.GetMetodSelectionMenu(agentType, new List <System.Type> { typeof(void) }, setValue.availableTypes, MethodSelected, 1, true); menu.ShowAsContext(); Event.current.Use(); } } if (!string.IsNullOrEmpty(methodName)) { GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Type", agentType.Name); EditorGUILayout.LabelField("Property", methodName); EditorGUILayout.LabelField("Set Type", EditorUtils.TypeName(setValue.selectedType)); GUILayout.EndVertical(); if (setValue.selectedType != null) { EditorUtils.BBVariableField("Set Value", setValue.selectedBBVariable); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { DrawDefaultInspector(); variableSet.selectedType = EditorUtils.Popup <System.Type>("Type", variableSet.selectedType, variableSet.availableTypes); if (variableSet.selectedBBVariable != null) { EditorUtils.BBVariableField("Value", variableSet.selectedBBVariable); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { EditorUtils.BBVariableField("Value A", valueA); (valueB as IMultiCastable).type = typeof(System.Enum); if (!valueA.isNone) { (valueB as IMultiCastable).type = valueA.value.GetType(); EditorUtils.BBVariableField("Value B", valueB); } }
/////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && agent == null && GUILayout.Button("Alter Type")) { System.Action <System.Type> TypeSelected = delegate(System.Type t){ var newTypeName = t.AssemblyQualifiedName; if (scriptName != newTypeName) { scriptName = newTypeName; methodName = null; } }; EditorUtils.ShowConfiguredTypeSelectionMenu(typeof(Component), TypeSelected); } if (!Application.isPlaying && GUILayout.Button("Select Property")) { System.Action <MethodInfo> MethodSelected = delegate(MethodInfo method){ scriptName = method.DeclaringType.AssemblyQualifiedName; methodName = method.Name; checkSet.selectedType = method.ReturnType; comparison = CompareMethod.EqualTo; }; if (agent != null) { EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, checkSet.availableTypes, null, MethodSelected, 0, true); } else { var menu = EditorUtils.GetMetodSelectionMenu(agentType, checkSet.availableTypes, null, MethodSelected, 0, true); menu.ShowAsContext(); Event.current.Use(); } } if (!string.IsNullOrEmpty(methodName)) { GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Selected Component", scriptName); EditorGUILayout.LabelField("Selected Property", methodName); GUILayout.EndVertical(); if (checkSet.selectedType != null) { GUI.enabled = checkSet.selectedType == typeof(float) || checkSet.selectedType == typeof(int); comparison = (CompareMethod)EditorGUILayout.EnumPopup("Comparison", comparison); GUI.enabled = true; EditorUtils.BBVariableField("Value", checkSet.selectedBBVariable); } } }
/////// protected override void OnTaskInspectorGUI() { EditorGUILayout.HelpBox(agent == null? "Agent is unknown.\nYou can select a type and a field" : "Agent is known.\nField selection will be done from existing components", MessageType.Info); if (!Application.isPlaying && agent == null && GUILayout.Button("Alter Type")) { System.Action <System.Type> TypeSelected = delegate(System.Type t){ var newName = t.AssemblyQualifiedName; if (scriptName != newName) { scriptName = newName; fieldName = null; } }; EditorUtils.ShowConfiguredTypeSelectionMenu(typeof(Component), TypeSelected); } if (!Application.isPlaying && GUILayout.Button("Select Field")) { System.Action <FieldInfo> FieldSelected = delegate(FieldInfo field){ scriptName = field.DeclaringType.AssemblyQualifiedName; fieldName = field.Name; setValue.selectedType = field.FieldType; }; if (agent != null) { EditorUtils.ShowGameObjectFieldSelectionMenu(agent.gameObject, setValue.availableTypes, FieldSelected); } else { var menu = EditorUtils.GetFieldSelectionMenu(agentType, setValue.availableTypes, FieldSelected); menu.ShowAsContext(); Event.current.Use(); } } if (!string.IsNullOrEmpty(fieldName)) { GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Type", agentType.Name); EditorGUILayout.LabelField("Field", fieldName); EditorGUILayout.LabelField("Field Type", EditorUtils.TypeName(setValue.selectedType)); GUILayout.EndVertical(); if (setValue.selectedType != null) { EditorUtils.BBVariableField("Set Value", setValue.selectedBBVariable); } } }
protected override void OnNodeInspectorGUI() { repeatType = (RepeatTypes)UnityEditor.EditorGUILayout.EnumPopup("Repeat Type", repeatType); if (repeatType == RepeatTypes.RepeatTimes) { repeatTimes = (BBInt)EditorUtils.BBVariableField("Repeat Times", repeatTimes); } else if (repeatType == RepeatTypes.RepeatUntil) { repeatUntil = (RepeatUntil)UnityEditor.EditorGUILayout.EnumPopup("Repeat Until", repeatUntil); } }
protected override void OnNodeInspectorGUI() { selectionMode = (SelectionMode)UnityEditor.EditorGUILayout.EnumPopup("Selection Mode", selectionMode); if (selectionMode == SelectionMode.IndexBased) { index = (BBInt)EditorUtils.BBVariableField("Index", index); } else { enumIndex = (BBEnum)EditorUtils.BBVariableField("Enum", enumIndex); } outOfRangeMode = (OutOfRangeMode)UnityEditor.EditorGUILayout.EnumPopup("When Out Of Range", outOfRangeMode); }
protected override void OnNodeInspectorGUI() { limitMode = (LimitMode)UnityEditor.EditorGUILayout.EnumPopup("Mode", limitMode); if (limitMode == LimitMode.CoolDown) { coolDownTime = (BBFloat)EditorUtils.BBVariableField("CoolDown Time", coolDownTime); } else if (limitMode == LimitMode.LimitNumberOfTimes) { maxCount = (BBInt)EditorUtils.BBVariableField("Max Times", maxCount); } inactiveWhenLimited = UnityEditor.EditorGUILayout.Toggle("Inactive When Limited", inactiveWhenLimited); }
/////// protected override void OnTaskInspectorGUI() { EditorGUILayout.HelpBox(agent == null? "Agent is unknown.\nYou can select a type and a method" : "Agent is known.\nMethod selection will be done from existing components", MessageType.Info); if (!Application.isPlaying && agent == null && GUILayout.Button("Alter Type")) { System.Action <System.Type> TypeSelected = delegate(System.Type t){ var newTypeName = t.AssemblyQualifiedName; if (scriptName != newTypeName) { scriptName = newTypeName; methodName = null; } }; EditorUtils.ShowConfiguredTypeSelectionMenu(typeof(Component), TypeSelected); } if (!Application.isPlaying && GUILayout.Button("Select Method")) { System.Action <MethodInfo> MethodSelected = delegate(MethodInfo method){ if (!typeof(Component).IsAssignableFrom(method.DeclaringType) && !method.DeclaringType.IsInterface) { return; } scriptName = method.DeclaringType.AssemblyQualifiedName; methodName = method.Name; var parameters = method.GetParameters(); paramNames = parameters.Select(p => EditorUtils.SplitCamelCase(p.Name)).ToList(); paramValue1.selectedType = parameters.Length >= 1? parameters[0].ParameterType : null; paramValue2.selectedType = parameters.Length >= 2? parameters[1].ParameterType : null; paramValue3.selectedType = parameters.Length >= 3? parameters[2].ParameterType : null; if (method.ReturnType == typeof(IEnumerator) || method.ReturnType == typeof(void) || method.ReturnType == typeof(Coroutine)) { returnValue.selectedType = null; } else { returnValue.selectedType = method.ReturnType; } //for gui isIEnumerator = method.ReturnType == typeof(IEnumerator); }; var returnTypes = returnValue.availableTypes; returnTypes.Add(typeof(void)); returnTypes.Add(typeof(IEnumerator)); returnTypes.Add(typeof(Coroutine)); var paramTypes = paramValue1.availableTypes; if (agent != null) { EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, returnTypes, paramTypes, MethodSelected, 3, false); } else { var menu = EditorUtils.GetMetodSelectionMenu(agentType, returnTypes, paramTypes, MethodSelected, 3, false); menu.ShowAsContext(); Event.current.Use(); } } if (!string.IsNullOrEmpty(methodName)) { GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Type", agentType.Name); EditorGUILayout.LabelField("Method", methodName); if (returnValue.selectedType != null) { EditorGUILayout.LabelField("Returns", EditorUtils.TypeName(returnValue.selectedType)); } if (isIEnumerator) { GUILayout.Label("<b>This will execute as a Coroutine</b>"); } GUILayout.EndVertical(); if (paramValue1.selectedType != null) { EditorUtils.BBVariableField(paramNames[0], paramValue1.selectedBBVariable); if (paramValue2.selectedType != null) { EditorUtils.BBVariableField(paramNames[1], paramValue2.selectedBBVariable); if (paramValue3.selectedType != null) { EditorUtils.BBVariableField(paramNames[2], paramValue3.selectedBBVariable); } } } if (returnValue.selectedType != null) { EditorUtils.BBVariableField("Save Return Value", returnValue.selectedBBVariable); } } }