Exemple #1
0
 public override void OnGUI()
 {
     if (boxChecked != (boxChecked = EditorGUILayout.Toggle(label, boxChecked)))
     {
         boxCheckedProperty.UpdateView(boxChecked);
     }
 }
Exemple #2
0
        public override void OnGUI()
        {
            var newOn = GUILayout.Toggle(@on, text);

            if (newOn != @on)
            {
                on = newOn;
                onProperty.UpdateView(newOn);
            }
        }
Exemple #3
0
        public override void OnGUI()
        {
            var newVector = EditorGUILayout.Vector3Field(new GUIContent(label, tooltip), vector);

            if (newVector != vector)
            {
                vector = newVector;
                vectorProperty.UpdateView(vector);
            }
        }
Exemple #4
0
        public override void OnGUI()
        {
            var newLayerMask = LayerMaskField(label, selectedLayerMask);

            if (selectedLayerMask != newLayerMask)
            {
                selectedLayerMask = newLayerMask;
                var newLayerNames = MaskToLayerNames(selectedLayerMask).ToArray();
                selectedLayersProperty.UpdateView(newLayerNames);
            }
        }
Exemple #5
0
        public override void OnGUI()
        {
            var itemStrings =
                items != null?items.Select(i => i.ToString()).ToArray() : new string[]
            {
            };

            var guiContent = itemStrings.Select(m => new GUIContent(m, tooltip)).ToArray();
            var newIndex   =
                !String.IsNullOrEmpty(label)
                ? EditorGUILayout.Popup(new GUIContent(label), selectedIndex, guiContent)
                : EditorGUILayout.Popup(selectedIndex, guiContent);

            if (newIndex != selectedIndex)
            {
                selectedIndex = newIndex;
                selectedItem  = items[selectedIndex];
                selectedItemProperty.UpdateView(selectedItem);
            }
        }
Exemple #6
0
        public override void OnGUI()
        {
            var layoutOptions = new List <GUILayoutOption>();

            if (width >= 0)
            {
                layoutOptions.Add(GUILayout.Width(width));
            }

            if (height >= 0)
            {
                layoutOptions.Add(GUILayout.Height(height));
            }

            string newText = height >= 0 // Use TextField if height isn't specified, otherwise use TextArea
                ? GUILayout.TextArea(text, layoutOptions.ToArray())
                : GUILayout.TextField(text, layoutOptions.ToArray());

            if (newText != text)
            {
                text = newText;
                textProperty.UpdateView(newText);
            }
        }
Exemple #7
0
        public override void OnGUI()
        {
            var layoutOptions = new List <GUILayoutOption>();

            if (width >= 0)
            {
                layoutOptions.Add(GUILayout.Width(width));
            }
            if (height >= 0)
            {
                layoutOptions.Add(GUILayout.Height(height));
            }

            // Make the background of the widget red if the date is invalid.
            var savedColour = UnityEngine.GUI.backgroundColor;

            if (!textValid)
            {
                UnityEngine.GUI.backgroundColor = Color.red;
            }
            string newText = GUILayout.TextField(text, layoutOptions.ToArray());

            UnityEngine.GUI.backgroundColor = savedColour;

            // Update the date
            if (newText != text)
            {
                text = newText;

                textValid = DateTime.TryParse(text, culture, DateTimeStyles.None, out date);
                if (textValid)
                {
                    dateProperty.UpdateView(date);
                }
            }
        }