/// <inheritoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            if (property.Type == SerializableProperty.FieldType.Vector2)
            {
                guiField = new GUIVector2Field(new GUIContent(title));
                guiField.OnComponentChanged += OnFieldValueChanged;
                guiField.OnConfirm          += x =>
                {
                    OnFieldValueConfirm();
                    StartUndo(x.ToString());
                };
                guiField.OnComponentFocusChanged += (focus, comp) =>
                {
                    if (focus)
                    {
                        StartUndo(comp.ToString());
                    }
                    else
                    {
                        OnFieldValueConfirm();
                    }
                };

                layout.AddElement(layoutIndex, guiField);
            }
        }
        /// <inheritoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            if (property.Type == SerializableProperty.FieldType.Vector2)
            {
                guiField              = new GUIVector2Field(new GUIContent(title));
                guiField.OnChanged   += OnFieldValueChanged;
                guiField.OnConfirmed += OnFieldValueConfirm;
                guiField.OnFocusLost += OnFieldValueConfirm;

                layout.AddElement(layoutIndex, guiField);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new material parameter GUI.
        /// </summary>
        /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of 2D vector type.</param>
        /// <param name="material">Material the parameter is a part of.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        internal MaterialParamVec2GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
            : base(shaderParam)
        {
            LocString title = new LocEdString(shaderParam.name);

            guiElem = new GUIVector2Field(title);
            guiElem.OnValueChanged += (x) =>
            {
                material.SetVector2(shaderParam.name, x);
                EditorApplication.SetDirty(material);
            };

            layout.AddElement(guiElem);
        }
 private static extern void Internal_create3(GUIVector2Field managedInstance, string style);
 private static extern void Internal_create2(GUIVector2Field managedInstance, LocString labelText, string style);
 private static extern void Internal_create0(GUIVector2Field managedInstance, ref GUIContent labelContent, string style);
 private static extern void Internal_CreateInstance(GUIVector2Field instance, ref GUIContent title, int titleWidth,
                                                    string style, GUIOption[] options, bool withTitle);