public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var e = (ParallelPassOptions)property.intValue; bool both = ((e & BOTH_ANY) == BOTH_ANY); bool failAny = e.HasFlag(ParallelPassOptions.FailOnAny); bool passAny = e.HasFlag(ParallelPassOptions.SucceedOnAny); bool passOnTie = e.HasFlag(ParallelPassOptions.SucceedOnTie); var r1 = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); var r2 = new Rect(position.xMin, r1.yMax, position.width, EditorGUIUtility.singleLineHeight); var r3 = new Rect(position.xMin, r2.yMax, position.width, EditorGUIUtility.singleLineHeight); EditorGUI.BeginChangeCheck(); failAny = EditorGUI.Popup(r1, "Fail", (failAny) ? 1 : 0, new string[] { "All", "Any" }) == 1; passAny = EditorGUI.Popup(r2, "Succeed", (passAny) ? 1 : 0, new string[] { "All", "Any" }) == 1; var cache = SPGUI.DisableIf(both); passOnTie = EditorGUI.Popup(r3, "Tie Breaker", (passOnTie) ? 1 : 0, new string[] { "Fail", "Succeed" }) == 1; cache.Reset(); if (EditorGUI.EndChangeCheck()) { e = 0; if (failAny) { e |= ParallelPassOptions.FailOnAny; } if (passAny) { e |= ParallelPassOptions.SucceedOnAny; } if (passOnTie) { e |= ParallelPassOptions.SucceedOnTie; } property.intValue = (int)e; } }
private void DrawValueFieldInValueMode(Rect position, SerializedProperty property, VariantReference.EditorHelper helper) { if (helper.Target == null) { return; } var variant = helper.Target; if (this.RestrictVariantType && helper._type != this.VariantTypeRestrictedTo) { helper.PrepareForValueTypeChange(this.VariantTypeRestrictedTo); GUI.changed = true; //force change } var r0 = new Rect(position.xMin, position.yMin, 90.0f, EditorGUIUtility.singleLineHeight); var r1 = new Rect(r0.xMax, position.yMin, position.xMax - r0.xMax, EditorGUIUtility.singleLineHeight); var cache = SPGUI.DisableIf(this.RestrictVariantType); EditorGUI.BeginChangeCheck(); var valueType = (VariantType)EditorGUI.EnumPopup(r0, GUIContent.none, variant.ValueType); if (EditorGUI.EndChangeCheck()) { helper.PrepareForValueTypeChange(valueType); } cache.Reset(); if (_typeRestrictedTo.IsEnum) { variant.IntValue = ConvertUtil.ToInt(EditorGUI.EnumPopup(r1, ConvertUtil.ToEnumOfType(_typeRestrictedTo, variant.IntValue))); } else { switch (valueType) { case VariantType.Null: cache = SPGUI.Disable(); EditorGUI.TextField(r1, "Null"); cache.Reset(); break; case VariantType.String: variant.StringValue = EditorGUI.TextField(r1, variant.StringValue); break; case VariantType.Boolean: variant.BoolValue = EditorGUI.Toggle(r1, variant.BoolValue); break; case VariantType.Integer: variant.IntValue = EditorGUI.IntField(r1, variant.IntValue); break; case VariantType.Float: variant.FloatValue = EditorGUI.FloatField(r1, variant.FloatValue); break; case VariantType.Double: variant.DoubleValue = ConvertUtil.ToDouble(EditorGUI.TextField(r1, variant.DoubleValue.ToString())); break; case VariantType.Vector2: variant.Vector2Value = EditorGUI.Vector2Field(r1, GUIContent.none, variant.Vector2Value); break; case VariantType.Vector3: variant.Vector3Value = EditorGUI.Vector3Field(r1, GUIContent.none, variant.Vector3Value); break; case VariantType.Vector4: variant.Vector4Value = EditorGUI.Vector4Field(r1, (string)null, variant.Vector4Value); break; case VariantType.Quaternion: variant.QuaternionValue = SPEditorGUI.QuaternionField(r1, GUIContent.none, variant.QuaternionValue); break; case VariantType.Color: variant.ColorValue = EditorGUI.ColorField(r1, variant.ColorValue); break; case VariantType.DateTime: variant.DateValue = ConvertUtil.ToDate(EditorGUI.TextField(r1, variant.DateValue.ToString())); break; case VariantType.GameObject: variant.GameObjectValue = EditorGUI.ObjectField(r1, variant.GameObjectValue, typeof(GameObject), true) as GameObject; break; case VariantType.Component: { _selectComponentDrawer.AllowNonComponents = false; _selectComponentDrawer.RestrictionType = _forcedObjectType; _selectComponentDrawer.ShowXButton = true; var targProp = property.FindPropertyRelative("_unityObjectReference"); EditorGUI.BeginChangeCheck(); _selectComponentDrawer.OnGUI(r1, targProp); if (EditorGUI.EndChangeCheck()) { variant.ComponentValue = targProp.objectReferenceValue as Component; } } break; case VariantType.Object: { var obj = variant.ObjectValue; if (ComponentUtil.IsAcceptableComponentType(_forcedObjectType)) { if (obj is GameObject || obj is Component) { _selectComponentDrawer.AllowNonComponents = false; _selectComponentDrawer.RestrictionType = _forcedObjectType; _selectComponentDrawer.ShowXButton = true; var targProp = property.FindPropertyRelative("_unityObjectReference"); EditorGUI.BeginChangeCheck(); _selectComponentDrawer.OnGUI(r1, targProp); if (EditorGUI.EndChangeCheck()) { variant.ObjectValue = targProp.objectReferenceValue as Component; } } else { EditorGUI.BeginChangeCheck(); obj = EditorGUI.ObjectField(r1, obj, typeof(UnityEngine.Object), true); if (EditorGUI.EndChangeCheck()) { if (obj == null) { variant.ObjectValue = null; } else if (TypeUtil.IsType(obj.GetType(), _forcedObjectType)) { variant.ObjectValue = obj; } else { var go = GameObjectUtil.GetGameObjectFromSource(obj); if (go != null) { variant.ObjectValue = go.GetComponent(_forcedObjectType); } else { variant.ObjectValue = null; } } } } } else { variant.ObjectValue = EditorGUI.ObjectField(r1, obj, _forcedObjectType, true); } } break; case VariantType.LayerMask: { variant.LayerMaskValue = SPEditorGUI.LayerMaskField(r1, GUIContent.none, (int)variant.LayerMaskValue); } break; case VariantType.Rect: { variant.RectValue = EditorGUI.RectField(r1, variant.RectValue); } break; } } }
protected Rect DrawPrimaryPortionOfInspector(Rect position, SerializedProperty property) { var r0 = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); var r1 = new Rect(position.xMin, r0.yMax, position.width, EditorGUIUtility.singleLineHeight); var r2 = new Rect(position.xMin, r1.yMax, position.width, EditorGUIUtility.singleLineHeight); EditorGUI.PropertyField(r0, property.FindPropertyRelative(PROP_REPEAT)); EditorGUI.PropertyField(r1, property.FindPropertyRelative(PROP_ALWAYSSUCEED)); var eloop = property.FindPropertyRelative(PROP_MODE).GetEnumValue <ActionGroupType>(); EditorGUI.PropertyField(r2, property.FindPropertyRelative(PROP_MODE), EditorHelper.TempContent("Loop Mode")); if (eloop == ActionGroupType.Parrallel) { EditorGUI.indentLevel++; var propOptions = property.FindPropertyRelative(PROP_OPTIONS); var e = (ParallelPassOptions)propOptions.intValue; bool both = ((e & BOTH_ANY) == BOTH_ANY); bool failAny = e.HasFlag(ParallelPassOptions.FailOnAny); bool passAny = e.HasFlag(ParallelPassOptions.SucceedOnAny); bool passOnTie = e.HasFlag(ParallelPassOptions.SucceedOnTie); var r3 = new Rect(position.xMin, r2.yMax, position.width, EditorGUIUtility.singleLineHeight); var r4 = new Rect(position.xMin, r3.yMax, position.width, EditorGUIUtility.singleLineHeight); var r5 = new Rect(position.xMin, r4.yMax, position.width, EditorGUIUtility.singleLineHeight); EditorGUI.BeginChangeCheck(); failAny = EditorGUI.Popup(r3, "Fail", (failAny) ? 1 : 0, new string[] { "All", "Any" }) == 1; passAny = EditorGUI.Popup(r4, "Succeed", (passAny) ? 1 : 0, new string[] { "All", "Any" }) == 1; var cache = SPGUI.DisableIf(both); passOnTie = EditorGUI.Popup(r5, "Tie Breaker", (passOnTie) ? 1 : 0, new string[] { "Fail", "Succeed" }) == 1; cache.Reset(); if (EditorGUI.EndChangeCheck()) { e = 0; if (failAny) { e |= ParallelPassOptions.FailOnAny; } if (passAny) { e |= ParallelPassOptions.SucceedOnAny; } if (passOnTie) { e |= ParallelPassOptions.SucceedOnTie; } propOptions.intValue = (int)e; } EditorGUI.indentLevel--; return(new Rect(position.xMin, r5.yMax, position.width, position.yMax - r5.yMax)); } else { return(new Rect(position.xMin, r2.yMax, position.width, position.yMax - r2.yMax)); } }