public Parameter.Type GetParameterType() { ParameterReferenceType parameterReferenceType = referenceProperty.type; Parameter.Type parameterType = Parameter.Type.Int; switch (parameterReferenceType) { case ParameterReferenceType.Constant: { Parameter parameter = referenceProperty.GetParameter(); if (parameter != null) { parameterType = parameter.type; } } break; case ParameterReferenceType.DataSlot: { parameterType = this.parameterType; } break; } return(parameterType); }
Parameter.Type GetParameterType() { ParameterReferenceProperty referenceProperty = GetParameterReference(); SerializedProperty parameterTypeProperty = serializedObject.FindProperty("_ParameterType"); ParameterReferenceType parameterReferenceType = referenceProperty.type; Parameter.Type parameterType = Parameter.Type.Int; switch (parameterReferenceType) { case ParameterReferenceType.Constant: { Parameter parameter = referenceProperty.GetParameter(); if (parameter != null) { parameterType = parameter.type; } } break; case ParameterReferenceType.DataSlot: { parameterType = EnumUtility.GetValueFromIndex <Parameter.Type>(parameterTypeProperty.enumValueIndex); } break; } return(parameterType); }
static bool HasFormatString(Parameter.Type type) { switch (type) { case Parameter.Type.Int: case Parameter.Type.Long: case Parameter.Type.Float: return(true); } return(false); }
public override void Contents(int _id) { for (int i = 0; i < graph.controller.parameters.Count; i++) { if (!graph.controller.parameters[i].Draw()) { graph.controller.RemoveParameter(graph.controller.parameters[i].name); graph.controller.parameters.RemoveAt(i); } } GUILayout.Space(20); GUILayout.BeginHorizontal(); newParameterName = EditorGUILayout.TextField("Parameter name: ", newParameterName); newParamterType = (Parameter.Type)EditorGUILayout.EnumPopup(newParamterType); EditorGUI.BeginDisabledGroup(graph.controller.HasParameter(newParameterName)); if (GUILayout.Button("Add")) { graph.controller.parameters.Add(new Parameter(newParameterName, newParamterType)); newParameterName = string.Empty; } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); }
void DeleteOldBranch(Parameter.Type parameterType) { SerializedProperty valueProperty = null; switch (parameterType) { case Parameter.Type.Int: { valueProperty = serializedObject.FindProperty("_IntValue"); } break; case Parameter.Type.Float: { valueProperty = serializedObject.FindProperty("_FloatValue"); } break; case Parameter.Type.Bool: { valueProperty = serializedObject.FindProperty("_BoolValue"); } break; case Parameter.Type.String: { valueProperty = serializedObject.FindProperty("_StringValue"); } break; case Parameter.Type.GameObject: { valueProperty = serializedObject.FindProperty("_GameObjectValue"); } break; case Parameter.Type.Vector2: { valueProperty = serializedObject.FindProperty("_Vector2Value"); } break; case Parameter.Type.Vector3: { valueProperty = serializedObject.FindProperty("_Vector3Value"); } break; case Parameter.Type.Quaternion: { valueProperty = serializedObject.FindProperty("_QuaternionValue"); } break; case Parameter.Type.Rect: { valueProperty = serializedObject.FindProperty("_RectValue"); } break; case Parameter.Type.Bounds: { valueProperty = serializedObject.FindProperty("_BoundsValue"); } break; case Parameter.Type.Color: { valueProperty = serializedObject.FindProperty("_ColorValue"); } break; case Parameter.Type.Transform: { valueProperty = serializedObject.FindProperty("_TransformValue"); } break; case Parameter.Type.RectTransform: { valueProperty = serializedObject.FindProperty("_RectTransformValue"); } break; case Parameter.Type.Rigidbody: { valueProperty = serializedObject.FindProperty("_RigidbodyValue"); } break; case Parameter.Type.Rigidbody2D: { valueProperty = serializedObject.FindProperty("_Rigidbody2DValue"); } break; case Parameter.Type.Component: { valueProperty = serializedObject.FindProperty("_ComponentValue"); } break; case Parameter.Type.Long: { valueProperty = serializedObject.FindProperty("_LongValue"); } break; } if (valueProperty != null) { foreach (object valueObj in EditorGUITools.GetPropertyObjects(valueProperty)) { EachField <DataSlot> .Find(valueObj, valueObj.GetType(), (s) => { s.Disconnect(); }); } } }
public override void OnInspectorGUI() { serializedObject.Update(); ParameterReferenceProperty referenceProperty = GetParameterReference(); SerializedProperty parameterTypeProperty = serializedObject.FindProperty("_ParameterType"); ClassTypeReferenceProperty referenceTypeProperty = new ClassTypeReferenceProperty(serializedObject.FindProperty("_ReferenceType")); Parameter.Type oldParameterType = GetParameterType(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(referenceProperty.property); if (EditorGUI.EndChangeCheck()) { Parameter.Type newParameterType = GetParameterType(); if (newParameterType != oldParameterType) { DeleteOldBranch(oldParameterType); } oldParameterType = newParameterType; } ParameterReferenceType parameterReferenceType = referenceProperty.type; if (parameterReferenceType == ParameterReferenceType.DataSlot) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(parameterTypeProperty); if (EditorGUI.EndChangeCheck()) { Parameter.Type newParameterType = GetParameterType(); if (newParameterType != oldParameterType) { DeleteOldBranch(oldParameterType); referenceTypeProperty.type = null; } oldParameterType = newParameterType; } switch (oldParameterType) { case Parameter.Type.Component: { System.Type oldReferenceType = referenceTypeProperty.type; referenceTypeProperty.property.SetStateData <ClassTypeConstraintAttribute>(ClassTypeConstraintEditorUtility.component); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(referenceTypeProperty.property); if (EditorGUI.EndChangeCheck()) { System.Type referenceType = referenceTypeProperty.type; if (referenceType != oldReferenceType) { DeleteOldBranch(oldParameterType); } oldReferenceType = referenceType; } } break; case Parameter.Type.Enum: { System.Type oldReferenceType = referenceTypeProperty.type; referenceTypeProperty.property.SetStateData <ClassTypeConstraintAttribute>(ClassTypeConstraintEditorUtility.enumField); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(referenceTypeProperty.property); if (EditorGUI.EndChangeCheck()) { System.Type referenceType = referenceTypeProperty.type; if (referenceType != oldReferenceType) { DeleteOldBranch(oldParameterType); } oldReferenceType = referenceType; } } break; } } Parameter.Type parameterType = GetParameterType(); SerializedProperty functionProperty = serializedObject.FindProperty("function"); switch (parameterType) { case Parameter.Type.Int: { EditorGUILayout.PropertyField(functionProperty); EditorGUILayout.PropertyField(serializedObject.FindProperty("_IntValue")); } break; case Parameter.Type.Long: { EditorGUILayout.PropertyField(functionProperty); EditorGUILayout.PropertyField(serializedObject.FindProperty("_LongValue")); } break; case Parameter.Type.Float: { EditorGUILayout.PropertyField(functionProperty); EditorGUILayout.PropertyField(serializedObject.FindProperty("_FloatValue")); } break; case Parameter.Type.Bool: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_BoolValue")); } break; case Parameter.Type.String: { EditorGUILayout.PropertyField(functionProperty); EditorGUILayout.PropertyField(serializedObject.FindProperty("_StringValue")); } break; case Parameter.Type.Enum: { SerializedProperty enumValueProperty = serializedObject.FindProperty("_EnumValue"); enumValueProperty.SetStateData(GetReferenceType()); EditorGUILayout.PropertyField(enumValueProperty); } break; case Parameter.Type.GameObject: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_GameObjectValue")); } break; case Parameter.Type.Vector2: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_Vector2Value")); } break; case Parameter.Type.Vector3: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_Vector3Value")); } break; case Parameter.Type.Quaternion: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_QuaternionValue")); } break; case Parameter.Type.Rect: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_RectValue")); } break; case Parameter.Type.Bounds: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_BoundsValue")); } break; case Parameter.Type.Color: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_ColorValue")); } break; case Parameter.Type.Transform: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_TransformValue")); } break; case Parameter.Type.RectTransform: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_RectTransformValue")); } break; case Parameter.Type.Rigidbody: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_RigidbodyValue")); } break; case Parameter.Type.Rigidbody2D: { EditorGUILayout.PropertyField(serializedObject.FindProperty("_Rigidbody2DValue")); } break; case Parameter.Type.Component: { SerializedProperty componentValueProperty = serializedObject.FindProperty("_ComponentValue"); componentValueProperty.SetStateData(GetReferenceType()); EditorGUILayout.PropertyField(componentValueProperty); } break; case Parameter.Type.Variable: { Parameter parameter = referenceProperty.GetParameter(); string valueTypeName = (parameter != null && parameter.valueType != null) ? parameter.valueType.ToString() : "Variable"; string message = string.Format(Localization.GetWord("CalcParameter.NotSupportVariable"), valueTypeName); EditorGUILayout.HelpBox(message, MessageType.Warning); } break; } serializedObject.ApplyModifiedProperties(); }
void ImportLegacy(ParameterConditionLegacy legacy) { ParameterReference parameterReference = legacy._Reference; Parameter parameter = parameterReference.parameter; Parameter.Type parameterType = parameter != null ? parameter.type : legacy._ParameterType; var condition = new ParameterCondition(); condition._Reference = legacy._Reference; condition._ParameterType = parameterType; condition._ReferenceType = legacy._ReferenceType; condition._CompareType = legacy._CompareType; switch (parameterType) { case Parameter.Type.Int: _IntParameters.Add(legacy._IntValue); condition._ParameterIndex = _IntParameters.Count - 1; break; case Parameter.Type.Long: _LongParameters.Add(legacy._LongValue); condition._ParameterIndex = _LongParameters.Count - 1; break; case Parameter.Type.Float: _FloatParameters.Add(legacy._FloatValue); condition._ParameterIndex = _FloatParameters.Count - 1; break; case Parameter.Type.Bool: _BoolParameters.Add(legacy._BoolValue); condition._ParameterIndex = _BoolParameters.Count - 1; break; case Parameter.Type.String: _StringParameters.Add(legacy._StringValue); condition._ParameterIndex = _StringParameters.Count - 1; break; case Parameter.Type.Enum: _EnumParameters.Add(legacy._EnumValue); condition._ParameterIndex = _EnumParameters.Count - 1; break; case Parameter.Type.GameObject: _GameObjectParameters.Add(legacy._GameObjectValue); condition._ParameterIndex = _GameObjectParameters.Count - 1; break; case Parameter.Type.Vector2: _Vector2Parameters.Add(legacy._Vector2Value); condition._ParameterIndex = _Vector2Parameters.Count - 1; break; case Parameter.Type.Vector3: _Vector3Parameters.Add(legacy._Vector3Value); condition._ParameterIndex = _Vector3Parameters.Count - 1; break; case Parameter.Type.Quaternion: _QuaternionParameters.Add(legacy._QuaternionValue); condition._ParameterIndex = _QuaternionParameters.Count - 1; break; case Parameter.Type.Rect: _RectParameters.Add(legacy._RectValue); condition._ParameterIndex = _RectParameters.Count - 1; break; case Parameter.Type.Bounds: _BoundsParameters.Add(legacy._BoundsValue); condition._ParameterIndex = _BoundsParameters.Count - 1; break; case Parameter.Type.Color: _ColorParameters.Add(legacy._ColorValue); condition._ParameterIndex = _ColorParameters.Count - 1; break; case Parameter.Type.Transform: _ComponentParameters.Add(legacy._TransformValue.ToFlexibleComponent()); condition._ParameterIndex = _ComponentParameters.Count - 1; break; case Parameter.Type.RectTransform: _ComponentParameters.Add(legacy._RectTransformValue.ToFlexibleComponent()); condition._ParameterIndex = _ComponentParameters.Count - 1; break; case Parameter.Type.Rigidbody: _ComponentParameters.Add(legacy._RigidbodyValue.ToFlexibleComponent()); condition._ParameterIndex = _ComponentParameters.Count - 1; break; case Parameter.Type.Rigidbody2D: _ComponentParameters.Add(legacy._Rigidbody2DValue.ToFlexibleComponent()); condition._ParameterIndex = _ComponentParameters.Count - 1; break; case Parameter.Type.Component: _ComponentParameters.Add(legacy._ComponentValue); condition._ParameterIndex = _ComponentParameters.Count - 1; break; case Parameter.Type.Variable: break; } condition.owner = this; _Conditions.Add(condition); }
private void ConditionGUI(ParameterConditionLegacyProperty conditionProperty) { Parameter.Type parameterType = conditionProperty.GetParameterType(); SerializedProperty compareTypeProperty = conditionProperty.compareTypeProperty; switch (parameterType) { case Parameter.Type.Int: { _LayoutArea.PropertyField(compareTypeProperty); _LayoutArea.PropertyField(conditionProperty.intValueProperty, EditorGUITools.GetTextContent("Int Value")); } break; case Parameter.Type.Long: { _LayoutArea.PropertyField(compareTypeProperty); _LayoutArea.PropertyField(conditionProperty.longValueProperty, EditorGUITools.GetTextContent("Long Value")); } break; case Parameter.Type.Float: { _LayoutArea.PropertyField(compareTypeProperty); _LayoutArea.PropertyField(conditionProperty.floatValueProperty, EditorGUITools.GetTextContent("Float Value")); } break; case Parameter.Type.Bool: { _LayoutArea.PropertyField(conditionProperty.boolValueProperty, EditorGUITools.GetTextContent("Bool Value")); } break; case Parameter.Type.String: { _LayoutArea.PropertyField(compareTypeProperty); _LayoutArea.PropertyField(conditionProperty.stringValueProperty, EditorGUITools.GetTextContent("String Value")); } break; case Parameter.Type.GameObject: { _LayoutArea.PropertyField(conditionProperty.gameObjectValueProperty, EditorGUITools.GetTextContent("GameObject Value")); } break; case Parameter.Type.Vector2: { _LayoutArea.PropertyField(conditionProperty.vector2ValueProperty, EditorGUITools.GetTextContent("Vector2 Value")); } break; case Parameter.Type.Vector3: { _LayoutArea.PropertyField(conditionProperty.vector3ValueProperty, EditorGUITools.GetTextContent("Vector3 Value")); } break; case Parameter.Type.Quaternion: { _LayoutArea.PropertyField(conditionProperty.quaternionValueProperty, EditorGUITools.GetTextContent("Quaternion Value")); } break; case Parameter.Type.Rect: { _LayoutArea.PropertyField(conditionProperty.rectValueProperty, EditorGUITools.GetTextContent("Rect Value")); } break; case Parameter.Type.Bounds: { _LayoutArea.PropertyField(conditionProperty.boundsValueProperty, EditorGUITools.GetTextContent("Bounds Value")); } break; case Parameter.Type.Color: { _LayoutArea.PropertyField(conditionProperty.colorValueProperty, EditorGUITools.GetTextContent("Color Value")); } break; case Parameter.Type.Transform: { _LayoutArea.PropertyField(conditionProperty.transformValueProperty, EditorGUITools.GetTextContent("Transform Value")); } break; case Parameter.Type.RectTransform: { _LayoutArea.PropertyField(conditionProperty.rectTransformValueProperty, EditorGUITools.GetTextContent("RectTransform Value")); } break; case Parameter.Type.Rigidbody: { _LayoutArea.PropertyField(conditionProperty.rigidbodyValueProperty, EditorGUITools.GetTextContent("Rigidbody Value")); } break; case Parameter.Type.Rigidbody2D: { _LayoutArea.PropertyField(conditionProperty.rigidbody2DValueProperty, EditorGUITools.GetTextContent("Rigidbody2D Value")); } break; case Parameter.Type.Component: { SerializedProperty componentValueProperty = conditionProperty.componentValueProperty; componentValueProperty.SetStateData(conditionProperty.GetReferenceType()); _LayoutArea.PropertyField(componentValueProperty, EditorGUITools.GetTextContent("Component Value")); } break; case Parameter.Type.Enum: { SerializedProperty enumValueProperty = conditionProperty.enumValueProperty; enumValueProperty.SetStateData(conditionProperty.GetReferenceType()); _LayoutArea.PropertyField(enumValueProperty, EditorGUITools.GetTextContent("Enum Value")); } break; case Parameter.Type.Variable: { Parameter parameter = conditionProperty.referenceProperty.GetParameter(); string valueTypeName = (parameter != null && parameter.valueType != null) ? parameter.valueType.ToString() : "Variable"; string message = string.Format(Localization.GetWord("ParameterCondition.NotSupportVariable"), valueTypeName); _LayoutArea.HelpBox(message, MessageType.Warning); } break; } }
void DoGUI(SerializedProperty property, GUIContent label) { ParameterConditionLegacyProperty conditionProperty = new ParameterConditionLegacyProperty(property); Parameter.Type oldParameterType = conditionProperty.GetParameterType(); EditorGUI.BeginChangeCheck(); _LayoutArea.PropertyField(conditionProperty.referenceProperty.property); if (EditorGUI.EndChangeCheck()) { Parameter.Type parameterType = conditionProperty.GetParameterType(); if (parameterType != oldParameterType) { DeleteOldBranch(conditionProperty, oldParameterType); } oldParameterType = parameterType; } ParameterReferenceType parameterReferenceType = conditionProperty.referenceProperty.type; if (parameterReferenceType == ParameterReferenceType.DataSlot) { EditorGUI.BeginChangeCheck(); _LayoutArea.PropertyField(conditionProperty.parameterTypeProperty); if (EditorGUI.EndChangeCheck()) { Parameter.Type parameterType = conditionProperty.GetParameterType(); if (parameterType != oldParameterType) { DeleteOldBranch(conditionProperty, oldParameterType); conditionProperty.referenceType = null; } oldParameterType = parameterType; } switch (oldParameterType) { case Parameter.Type.Component: { System.Type oldReferenceType = conditionProperty.referenceType; conditionProperty.referenceTypeProperty.property.SetStateData <ClassTypeConstraintAttribute>(ClassTypeConstraintEditorUtility.component); EditorGUI.BeginChangeCheck(); _LayoutArea.PropertyField(conditionProperty.referenceTypeProperty.property); if (EditorGUI.EndChangeCheck()) { System.Type referenceType = conditionProperty.referenceType; if (referenceType != oldReferenceType) { DeleteOldBranch(conditionProperty, oldParameterType); } oldReferenceType = referenceType; } } break; case Parameter.Type.Enum: { System.Type oldReferenceType = conditionProperty.referenceType; conditionProperty.referenceTypeProperty.property.SetStateData <ClassTypeConstraintAttribute>(ClassTypeConstraintEditorUtility.enumField); EditorGUI.BeginChangeCheck(); _LayoutArea.PropertyField(conditionProperty.referenceTypeProperty.property); if (EditorGUI.EndChangeCheck()) { System.Type referenceType = conditionProperty.referenceType; if (referenceType != oldReferenceType) { DeleteOldBranch(conditionProperty, oldParameterType); } oldReferenceType = referenceType; } } break; } } if (parameterReferenceType == ParameterReferenceType.DataSlot || conditionProperty.referenceProperty.container != null) { ConditionGUI(conditionProperty); } }
void DeleteOldBranch(ParameterConditionLegacyProperty conditionProperty, Parameter.Type type) { SerializedProperty valueProperty = null; switch (type) { case Parameter.Type.Int: { valueProperty = conditionProperty.intValueProperty; } break; case Parameter.Type.Long: { valueProperty = conditionProperty.longValueProperty; } break; case Parameter.Type.Float: { valueProperty = conditionProperty.floatValueProperty; } break; case Parameter.Type.Bool: { valueProperty = conditionProperty.boolValueProperty; } break; case Parameter.Type.String: { valueProperty = conditionProperty.stringValueProperty; } break; case Parameter.Type.GameObject: { valueProperty = conditionProperty.gameObjectValueProperty; } break; case Parameter.Type.Vector2: { valueProperty = conditionProperty.vector2ValueProperty; } break; case Parameter.Type.Vector3: { valueProperty = conditionProperty.vector3ValueProperty; } break; case Parameter.Type.Quaternion: { valueProperty = conditionProperty.quaternionValueProperty; } break; case Parameter.Type.Rect: { valueProperty = conditionProperty.rectValueProperty; } break; case Parameter.Type.Bounds: { valueProperty = conditionProperty.boundsValueProperty; } break; case Parameter.Type.Color: { valueProperty = conditionProperty.colorValueProperty; } break; case Parameter.Type.Transform: { valueProperty = conditionProperty.transformValueProperty; } break; case Parameter.Type.RectTransform: { valueProperty = conditionProperty.rectTransformValueProperty; } break; case Parameter.Type.Rigidbody: { valueProperty = conditionProperty.rigidbodyValueProperty; } break; case Parameter.Type.Rigidbody2D: { valueProperty = conditionProperty.rigidbody2DValueProperty; } break; case Parameter.Type.Component: { valueProperty = conditionProperty.componentValueProperty; } break; } if (valueProperty != null) { foreach (object valueObj in EditorGUITools.GetPropertyObjects(valueProperty)) { EachField <DataSlot> .Find(valueObj, valueObj.GetType(), (s) => { s.Disconnect(); }); } } }