/// <summary>
        ///   Edits the specified context.
        /// </summary>
        /// <param name="context">Editor context to work with.</param>
        public void Edit(IValueEditorContext context)
        {
            // Get value.
            object value = context.Value;
            string oldValue = value != null ? (string)value : string.Empty;

            // Show editor.
            GUILayout.BeginHorizontal();
            GUILayout.Label(context.Name);
            string newValue = GUILayout.TextField(oldValue);
            GUILayout.EndHorizontal();

            // Set new value.
            if (newValue != oldValue)
            {
                context.Value = newValue;
            }
        }
Esempio n. 2
0
        /// <summary>
        ///   Edits the specified context.
        /// </summary>
        /// <param name="context">Editor context to work with.</param>
        public void Edit(IValueEditorContext context)
        {
            // Get value.
            object value    = context.Value;
            string oldValue = value != null ? (string)value : string.Empty;

            // Show editor.
            GUILayout.BeginHorizontal();
            GUILayout.Label(context.Name);
            string newValue = GUILayout.TextField(oldValue);

            GUILayout.EndHorizontal();

            // Set new value.
            if (newValue != oldValue)
            {
                context.Value = newValue;
            }
        }
Esempio n. 3
0
        /// <summary>
        ///   Edits the specified context.
        /// </summary>
        /// <param name="context"> Editor context to work with. </param>
        public void Edit(IValueEditorContext context)
        {
            // Get value.
            Vector2I oldValue = context.GetValue <Vector2I>();

            // Show editor.
            GUILayout.BeginHorizontal();
            GUILayout.Label(context.Name);
            int    newX;
            string newXString = GUILayout.TextField(oldValue.X.ToString(CultureInfo.InvariantCulture));

            if (string.IsNullOrEmpty(newXString))
            {
                newX = 0;
            }
            else if (!int.TryParse(newXString, out newX))
            {
                newX = oldValue.X;
            }

            int    newY;
            string newYString = GUILayout.TextField(oldValue.Y.ToString(CultureInfo.InvariantCulture));

            if (string.IsNullOrEmpty(newYString))
            {
                newY = 0;
            }
            else if (!int.TryParse(newYString, out newY))
            {
                newY = oldValue.Y;
            }
            Vector2I newValue = new Vector2I(newX, newY);

            GUILayout.EndHorizontal();

            // Set new value.
            if (newValue != oldValue)
            {
                context.Value = newValue;
            }
        }
Esempio n. 4
0
        /// <summary>
        ///   Edits the specified context.
        /// </summary>
        /// <param name="context">Editor context to work with.</param>
        public void Edit(IValueEditorContext context)
        {
            if (!ReflectionUtils.IsEnum(context.Type))
            {
                throw new ArgumentException(string.Format("Type '{0}' is no enum type.", context.Type), "context");
            }

            // Get enum value.
            Array enumValues = Enum.GetValues(context.Type);
            int   selectedItem;
            Enum  value;

            if (context.Value != null)
            {
                value        = (Enum)context.Value;
                selectedItem = Array.IndexOf(enumValues, value);
            }
            else
            {
                // Take first value of enum type.
                value        = (Enum)enumValues.GetValue(0);
                selectedItem = 0;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label(context.Name);
            bool showList;

            this.showPopupList.TryGetValue(context.Key, out showList);
            int newSelectedItem = GUILayoutExt.Popup(selectedItem, Enum.GetNames(context.Type), ref showList);

            this.showPopupList[context.Key] = showList;
            GUILayout.EndHorizontal();

            if (newSelectedItem != selectedItem)
            {
                context.Value = enumValues.GetValue(newSelectedItem);
            }
        }
        /// <summary>
        ///   Edits the specified context.
        /// </summary>
        /// <param name="context"> Editor context to work with. </param>
        public void Edit(IValueEditorContext context)
        {
            // Get value.
            Vector2I oldValue = context.GetValue<Vector2I>();

            // Show editor.
            GUILayout.BeginHorizontal();
            GUILayout.Label(context.Name);
            int newX;
            string newXString = GUILayout.TextField(oldValue.X.ToString(CultureInfo.InvariantCulture));
            if (string.IsNullOrEmpty(newXString))
            {
                newX = 0;
            }
            else if (!int.TryParse(newXString, out newX))
            {
                newX = oldValue.X;
            }

            int newY;
            string newYString = GUILayout.TextField(oldValue.Y.ToString(CultureInfo.InvariantCulture));
            if (string.IsNullOrEmpty(newYString))
            {
                newY = 0;
            }
            else if (!int.TryParse(newYString, out newY))
            {
                newY = oldValue.Y;
            }
            Vector2I newValue = new Vector2I(newX, newY);
            GUILayout.EndHorizontal();

            // Set new value.
            if (newValue != oldValue)
            {
                context.Value = newValue;
            }
        }
        /// <summary>
        ///   Edits the specified context.
        /// </summary>
        /// <param name="context">Editor context to work with.</param>
        public void Edit(IValueEditorContext context)
        {
            if (!ReflectionUtils.IsEnum(context.Type))
            {
                throw new ArgumentException(string.Format("Type '{0}' is no enum type.", context.Type), "context");
            }

            // Get enum value.
            Array enumValues = Enum.GetValues(context.Type);
            int selectedItem;
            Enum value;
            if (context.Value != null)
            {
                value = (Enum)context.Value;
                selectedItem = Array.IndexOf(enumValues, value);
            }
            else
            {
                // Take first value of enum type.
                value = (Enum)enumValues.GetValue(0);
                selectedItem = 0;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label(context.Name);
            bool showList;
            this.showPopupList.TryGetValue(context.Key, out showList);
            int newSelectedItem = GUILayoutExt.Popup(selectedItem, Enum.GetNames(context.Type), ref showList);
            this.showPopupList[context.Key] = showList;
            GUILayout.EndHorizontal();

            if (newSelectedItem != selectedItem)
            {
                context.Value = enumValues.GetValue(newSelectedItem);
            }
        }
 /// <summary>
 ///   Edits the specified context.
 /// </summary>
 /// <param name="context"> Editor context to work with. </param>
 public void Edit(IValueEditorContext context)
 {
     throw new NotImplementedException();
 }