コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Set the unused derived classes of InputSelectorBase to null to not waste memory on runtime startup
 /// </summary>
 private void NullUnusedTypes()
 {
     if (inputType != InputType.Axis)
     {
         inputAxis = null;
     }
     if (inputType != InputType.KeyCode)
     {
         inputKeyCode = null;
     }
     if (inputType != InputType.Keys)
     {
         inputKeys = null;
     }
     if (inputType != InputType.UIZone)
     {
         inputUIZone = null;
     }
     if (inputType != InputType.TouchArea)
     {
         inputTouchArea = null;
     }
 }
コード例 #3
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            InputSelectorUIZone inputSelector = PropertyDrawerUtility.GetParent(property) as InputSelectorUIZone;
            //int index = PropertyDrawerUtility.GetIndexOfDrawerObject(property);
            UIZoneSelector _target = inputSelector.zoneSelector;

            // Get the array of zoneNames
            List <string> zonesnamelist = UIZone.names;            // GetListOfZoneNames();

            // only resize the string array when it doesn't match the number of UIZones in scene
            if (zonesnamelist.Count != zonenames.Length)
            {
                zonenames = new string[zonesnamelist.Count];
            }

            for (int i = 0; i < zonesnamelist.Count; i++)
            {
                zonenames[i] = zonesnamelist[i];
            }

            if (zonesnamelist.Count == 0)
            {
                EditorUtils.CreateErrorIconF(r.xMin, r.yMin, "Add a UIZone component to a UI object to define a touch/mouse area. Any added zones will appear in a list here for you to select from.");

                EditorGUI.LabelField(r, "     No UIZones found in scene.", new GUIStyle("MiniLabel"));
            }
            else
            {
                if (_target != null)
                {
                    _target.ZoneId   = EditorGUI.Popup(r, _target.ZoneId, zonenames);
                    _target.ZoneName = UIZone.list[_target.ZoneId].itemName;
                }

                //selectedZoneName.stringValue = zonenames[selectedZoneId.intValue];
            }
        }