public override bool LoadProtoBuf(BehaviorPB.Node node) { if (!base.LoadProtoBuf(node)) return false; if (node.condition == null) return false; scriptPath = node.condition.script_path; conditionType = (Condition.Type)Type; return true; }
protected Condition(Condition.Type type, Condition.Comparator comparator, params object[] args) { this.type = type; this.comparator = comparator; this.args = args; }
internal bool HasCondition(Condition.Type type) { return(Conditions.Any(c => c.Name == type)); }
internal Condition GetConditionByType(Condition.Type type) { return(Conditions.FirstOrDefault(c => c.Name == type)); }
public PrivateCondition(Condition.Type type, Condition.Comparator comparator, params object[] args) : base(type, comparator, args) { }
public void registerCondition(Condition.Type type, Condition.CompareHandler ch) { compares[(int)type] = ch; }
public Condition.CompareHandler getCompareHandler(Condition.Type type) { return(compares[(int)type]); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { label = EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, label); Initialize(property); Debug.Assert(_typeProperty != null); Debug.Assert(_comparisonProperty != null); Debug.Assert(_intPair != null); Debug.Assert(_floatPair != null); Debug.Assert(_stringPair != null); Debug.Assert(_boolPair != null); Rect typeRect, varRect, operationRect, otherRect; CalculateRects(position, out typeRect, out varRect, out operationRect, out otherRect); EditorGUI.BeginChangeCheck(); //Store old indent level and set it to 0, the PrefixLabel takes care of it //int indent = EditorGUI.indentLevel; //EditorGUI.indentLevel = 0; Condition.Type type = (Condition.Type)EditorGUI.EnumPopup(typeRect, (Condition.Type)_typeProperty.enumValueIndex);; _typeProperty.enumValueIndex = (int)type; if (EditorGUI.EndChangeCheck() || _pairPropertyHolder == null) { property.serializedObject.ApplyModifiedProperties(); switch (type) { case Condition.Type.Bool: _pairPropertyHolder = new PairPropertyHolder(_boolPair); break; case Condition.Type.Float: _pairPropertyHolder = new PairPropertyHolder(_floatPair); break; case Condition.Type.Int: _pairPropertyHolder = new PairPropertyHolder(_intPair); break; case Condition.Type.String: _pairPropertyHolder = new PairPropertyHolder(_stringPair); break; default: throw new ArgumentOutOfRangeException(); } } EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(varRect, _pairPropertyHolder.variableProperty, GUIContent.none); if (EditorGUI.EndChangeCheck() || _options == null) { property.serializedObject.ApplyModifiedProperties(); Variable.Comparison[] comparisons = _pairPropertyHolder.pair.GetGenericVariable().GetPermittedComparisons().ToArray(); _options = new GUIContent[comparisons.Length]; for (int i = 0; i < comparisons.Length; i++) { _options[i] = new GUIContent(_dictionary[comparisons[i]]); } } _comparisonProperty.enumValueIndex = EditorGUI.Popup(operationRect, _comparisonProperty.enumValueIndex, _options); EditorGUI.PropertyField(otherRect, _pairPropertyHolder.referenceProperty, GUIContent.none); if (EditorGUI.EndChangeCheck()) { property.serializedObject.ApplyModifiedProperties(); } //EditorGUI.indentLevel = indent; EditorGUI.EndProperty(); }
public CommonCondition(CompareHandler ch, Condition.Type type, Condition.Comparator comparator, params object[] args) : base(type, comparator, args) { this.ch = ch; }