예제 #1
0
        protected override bool OnDraw(IDrawContext context)
        {
            var value = ((char)Value).ToString(CultureInfo.InvariantCulture);

            context.BeginLook(true);
            try
            {
                string newValue = EditorGUILayout.TextField(value);
                if (newValue.Length != 0)
                {
                    if (newValue.Length > 1)
                    {
                        newValue = newValue.Remove(0, newValue.Length - 1);
                    }

                    if (!newValue.Equals(value))
                    {
                        Value = char.Parse(newValue);
                        return(true);
                    }
                }
                return(false);
            }
            finally { context.EndLook(); }
        }
예제 #2
0
        protected override bool OnDraw(IDrawContext context, bool isNewAreaStarted)
        {
            context.BeginLook(true);
            var v     = (Ray)Value;
            var prevV = v;

            v.origin    = EditorGUILayout.Vector3Field("Origin", v.origin);
            v.direction = EditorGUILayout.Vector3Field("Direction", v.origin);
            context.EndLook();
            if (!prevV.Equals(v))
            {
                Value = v;
                return(true);
            }
            return(false);
        }
예제 #3
0
        protected override bool OnDraw(IDrawContext context)
        {
            var value = (String)Value;

            context.BeginLook(true);
            try
            {
                object newValue = EditorGUILayout.TextField(value);
                if (!newValue.Equals(value))
                {
                    Value = newValue;
                    return(true);
                }
                return(false);
            }
            finally { context.EndLook(); }
        }
예제 #4
0
        protected override bool OnDraw(IDrawContext context, bool isNewAreaStarted)
        {
            var value = (Color)Value;

            context.BeginLook(true);
            try
            {
                object newValue = EditorGUILayout.ColorField(value);
                if (!newValue.Equals(value))
                {
                    Value = newValue;
                    return(true);
                }
                return(false);
            }
            finally { context.EndLook(); }
        }
예제 #5
0
        protected override bool OnDraw(IDrawContext context, bool isNewAreaStarted)
        {
            GUILayout.Space(15f);
            var value = (Boolean)Value;

            context.BeginLook(false);
            try
            {
                object newValue = EditorGUILayout.Toggle(value, StylesCache.toggle);
                if (!newValue.Equals(value))
                {
                    Value = newValue;
                    return(true);
                }
                return(false);
            }
            finally { context.EndLook(); }
        }
예제 #6
0
        protected override bool OnDraw(IDrawContext context, bool isNewAreaStarted)
        {
            var value = (Quaternion)Value;

            context.BeginLook(true);
            try
            {
                const string autoLabel = "Euler Angles";
                string       label     = InitArgs.Label != null ? InitArgs.Label.text : autoLabel;
                if (string.IsNullOrEmpty(label))
                {
                    label = autoLabel;
                }
                object newValue = Quaternion.Euler(EditorGUILayout.Vector3Field(label, value.eulerAngles));
                if (!newValue.Equals(value))
                {
                    Value = newValue;
                    return(true);
                }
                return(false);
            }
            finally { context.EndLook(); }
        }
예제 #7
0
        protected override bool OnDraw(IDrawContext context)
        {
            Type type  = InitArgs.SupportedType;
            int  value = (int)Convert.ChangeType(Value, TypeCode.Int32);

            context.BeginLook(true);
            try
            {
                object newValue;
                try
                {
                    newValue = Convert.ChangeType(EditorGUILayout.IntField(value), type);
                }
                catch { return(false); }

                if (!newValue.Equals(value))
                {
                    Value = newValue;
                    return(true);
                }
                return(false);
            }
            finally { context.EndLook(); }
        }
예제 #8
0
        protected override bool OnDraw(IDrawContext context, bool isNewAreaStarted)
        {
            var  value       = (string)Value ?? string.Empty;
            bool hasLineEnds = value.Contains("\n");
            bool expanded    = _expanded || hasLineEnds;

            context.BeginLook(true);
            object newValue;

            try
            {
                if (expanded)
                {
                    newValue = EditorGUILayout.TextArea(value, GUILayout.MinHeight(50f));
                }
                else
                {
                    newValue = EditorGUILayout.TextField(value);

                    if (GUILayout.Button("↓", GUILayout.Width(20f)))
                    {
                        _expanded = true;
                    }
                }
            }
            finally
            {
                context.EndLook();
            }
            if (!newValue.Equals(value))
            {
                Value = newValue;
                return(true);
            }
            return(false);
        }