public override void OnGUI(Rect r, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(r, label, property); InputSelector par = (InputSelector)PropertyDrawerUtility.GetParent(property); // Initialize constantly to apply changes par.inputSelection.Initialize(par); //var _target = PropertyDrawerUtility.GetActualObjectForSerializedProperty<InputSelectorKeyCode>(fieldInfo, property); //Debug.Log(_target); //int id = PropertyDrawerUtility.GetIndexOfDrawerObject(property); //Debug.Log(par); index = property.FindPropertyRelative("index"); modKeys = property.FindPropertyRelative("modKeys"); castInputType = property.FindPropertyRelative("inputType"); halfFieldWidth = r.width * .5f; firstFieldLeft = r.xMin; secondFieldLeft = r.xMin + halfFieldWidth; if (!isTouch) { int oldVal = modKeys.intValue; int newVal = (int)(ModKeys)EditorGUI.EnumMaskPopup(new Rect(r.xMin, r.yMin, halfFieldWidth, r.height), GUIContent.none, (ModKeys)modKeys.intValue); // if UnModded has just been selected - clamp to clear all other mods if (newVal - oldVal >= (int)ModKeys.UnModded) { newVal = (int)ModKeys.UnModded; } // else if a mod has been selected, clear unmodded else if (newVal > (int)ModKeys.UnModded) { newVal = newVal & ~((int)ModKeys.UnModded); } modKeys.intValue = newVal; } EditorGUI.EndProperty(); }
public override void OnGUI(Rect r, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(r, label, property); InputSelector par = (InputSelector)PropertyDrawerUtility.GetParent(property); // Initialize constantly to apply changes par.inputSelection.Initialize(par); index = property.FindPropertyRelative("index"); modKeys = property.FindPropertyRelative("modKeys"); castInputType = property.FindPropertyRelative("inputType"); halfFieldWidth = r.width * .5f; firstFieldLeft = r.xMin; secondFieldLeft = r.xMin + halfFieldWidth; if (!isTouch) { int oldVal = modKeys.intValue; #if UNITY_2017_3_OR_NEWER int newVal = (int)(ModKeys)EditorGUI.EnumFlagsField(new Rect(r.xMin, r.yMin, halfFieldWidth, r.height), GUIContent.none, (ModKeys)modKeys.intValue); #else int newVal = (int)(ModKeys)EditorGUI.EnumMaskField(new Rect(r.xMin, r.yMin, halfFieldWidth, r.height), GUIContent.none, (ModKeys)modKeys.intValue); #endif // if UnModded has just been selected - clamp to clear all other mods if (newVal - oldVal >= (int)ModKeys.UnModded) { newVal = (int)ModKeys.UnModded; } // else if a mod has been selected, clear unmodded else if (newVal > (int)ModKeys.UnModded) { newVal = newVal & ~((int)ModKeys.UnModded); } modKeys.intValue = newVal; } EditorGUI.EndProperty(); }
public override void OnGUI(Rect r, SerializedProperty property, GUIContent label) { InputSelector inputSelector = PropertyDrawerUtility.GetParent(property) as InputSelector; InputSelectorUIZone _target = inputSelector.inputSelection as InputSelectorUIZone; // Tell the base class that this is a touch/click item - so the modkeys are not needed. isTouch = true; base.OnGUI(r, property, label); SerializedProperty touchTypes = property.FindPropertyRelative("touchType"); SerializedProperty zoneSelector = property.FindPropertyRelative("zoneSelector"); { if (_target != null) { touchTypes.enumValueIndex = (int)(ClickTypes)EditorGUI.EnumPopup(new Rect(firstFieldLeft, r.yMin, halfFieldWidth, 16), GUIContent.none, (ClickTypes)touchTypes.enumValueIndex); EditorGUI.PropertyField(new Rect(secondFieldLeft, r.yMin, halfFieldWidth, 16), zoneSelector); } } }
public override void Initialize(InputSelector _parent) { base.Initialize(_parent); UpdateRect(); }
private List <KeyCode> modKeysList = new List <KeyCode>(); // broken down list of mod keys to actually test for at runtime public virtual void Initialize(InputSelector _parent) { parent = _parent; CacheModKeys(); }
public override void Initialize(InputSelector _parent) { base.Initialize(_parent); ExtractKeys(); }
public override void OnGUI(Rect r, SerializedProperty property, GUIContent label) { InputSelector _target = null; EditorGUI.BeginProperty(r, label, property); // Very roundabout way of getting this target if is part of a list. var _parent = PropertyDrawerUtility.GetParent(property); int index = PropertyDrawerUtility.GetIndexOfDrawerObject(property); if (_parent != null && _parent is InputSelectors && index != -1) { _target = (_parent as InputSelectors).selectors [index]; } // This is not part of a list... if (_target == null) { _target = PropertyDrawerUtility.GetActualObjectForSerializedProperty <InputSelector>(fieldInfo, property); } if (_target != null) { _target.UpdateToSelectedType(); } // This will need to be an interface in order to be useable on more than just NSTCastDefinition //NSTCastDefinition nstCastDef = property.serializedObject.targetObject as NSTCastDefinition; SerializedProperty inputType = property.FindPropertyRelative("inputType"); //SerializedProperty inputSelection = property.FindPropertyRelative("triggers"); labelWidth = EditorGUIUtility.labelWidth - 36; fieldWidth = r.width - labelWidth; halfFieldWidth = fieldWidth * .5f; fieldAreaLeft = r.xMin + labelWidth; int val = (int)(InputType)EditorGUI.EnumPopup(new Rect(r.xMin, r.yMin, labelWidth - 2, 16), GUIContent.none, (InputType)inputType.enumValueIndex); inputType.enumValueIndex = val; Rect rightrect = new Rect(fieldAreaLeft, r.yMin, fieldWidth, r.height); InputType enumVal = (InputType)val; // Only show the derived input class that we are actually using if (enumVal == InputType.Axis) { EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputAxis")); } else if (enumVal == InputType.KeyCode) { EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputKeyCode")); } else if (enumVal == InputType.Keys) { EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputKeys")); } else if (enumVal == InputType.UIZone) { EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputUIZone")); } else if (enumVal == InputType.TouchArea) { EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputTouchArea")); } EditorGUI.EndProperty(); }