/// <inheritoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            if (property.Type == SerializableProperty.FieldType.Vector3)
            {
                guiField = new GUIVector3Field(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.Vector3)
            {
                guiField              = new GUIVector3Field(new GUIContent(title));
                guiField.OnChanged   += OnFieldValueChanged;
                guiField.OnConfirmed += OnFieldValueConfirm;
                guiField.OnFocusLost += OnFieldValueConfirm;

                layout.AddElement(layoutIndex, guiField);
            }
        }
示例#3
0
        /// <summary>
        /// Creates a new material parameter GUI.
        /// </summary>
        /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of 3D 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 MaterialParamVec3GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
            : base(shaderParam)
        {
            LocString title = new LocEdString(shaderParam.name);

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

            layout.AddElement(guiElem);
        }
示例#4
0
        /// <summary>
        /// Destroys all inspector GUI elements.
        /// </summary>
        internal void Clear()
        {
            for (int i = 0; i < inspectorComponents.Count; i++)
            {
                inspectorComponents[i].foldout.Destroy();
                inspectorComponents[i].removeBtn.Destroy();
                inspectorComponents[i].inspector.Destroy();
            }

            inspectorComponents.Clear();

            if (inspectorResource != null)
            {
                inspectorResource.inspector.Destroy();
                inspectorResource = null;
            }

            if (inspectorScrollArea != null)
            {
                inspectorScrollArea.Destroy();
                inspectorScrollArea = null;
            }

            if (scrollAreaHighlight != null)
            {
                scrollAreaHighlight.Destroy();
                scrollAreaHighlight = null;
            }

            if (highlightPanel != null)
            {
                highlightPanel.Destroy();
                highlightPanel = null;
            }

            activeSO       = null;
            soNameInput    = null;
            soActiveToggle = null;
            soMobility     = null;
            soPrefabLayout = null;
            soHasPrefab    = false;
            soPos          = null;
            soRot          = null;
            soScale        = null;
            dropAreas      = new Rect2I[0];

            activeResourcePath = null;
            currentType        = InspectorType.None;
        }
示例#5
0
        /// <inheritoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            if (property.Type == SerializableProperty.FieldType.Quaternion)
            {
                guiField       = new GUIVector3Field(new GUIContent(title));
                guiField.Value = quatValue.ToEuler();

                guiField.OnValueChanged += OnFieldValueChanged;
                guiField.OnConfirm      += x => OnFieldValueConfirm();
                guiField.OnFocusLost    += OnFieldValueConfirm;
                guiField.OnFocusGained  += RecordStateForUndoRequested;

                layout.AddElement(layoutIndex, guiField);
            }
        }
示例#6
0
        /// <inheritoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            GUILayoutX boundsLayout = new GUILayoutX();

            centerField = new GUIVector3Field(new LocEdString("Center"), 50);
            sizeField   = new GUIVector3Field(new LocEdString("Size"), 50);

            layout.AddElement(layoutIndex, boundsLayout);

            boundsLayout.AddElement(new GUILabel(new LocEdString(title), GUIOption.FixedWidth(100)));

            GUILayoutY boundsContent = boundsLayout.AddLayoutY();

            boundsContent.AddElement(centerField);
            boundsContent.AddElement(sizeField);

            centerField.OnValueChanged += x =>
            {
                AABox   bounds = property.GetValue <AABox>();
                Vector3 min    = x - bounds.Size * 0.5f;
                Vector3 max    = x + bounds.Size * 0.5f;

                RecordStateForUndoIfNeeded();
                property.SetValue(new AABox(min, max));
                state |= InspectableState.ModifyInProgress;
            };
            centerField.OnConfirm     += x => OnFieldValueConfirm();
            centerField.OnFocusLost   += OnFieldValueConfirm;
            centerField.OnFocusGained += RecordStateForUndoRequested;

            sizeField.OnValueChanged += x =>
            {
                AABox   bounds = property.GetValue <AABox>();
                Vector3 min    = bounds.Center - x * 0.5f;
                Vector3 max    = bounds.Center + x * 0.5f;

                RecordStateForUndoIfNeeded();
                property.SetValue(new AABox(min, max));
                state |= InspectableState.ModifyInProgress;
            };
            sizeField.OnConfirm     += x => OnFieldValueConfirm();
            sizeField.OnFocusLost   += OnFieldValueConfirm;
            sizeField.OnFocusGained += RecordStateForUndoRequested;
        }
示例#7
0
        /// <summary>
        /// Creates GUI elements required for displaying <see cref="SceneObject"/> fields like name, prefab data and
        /// transform (position, rotation, scale). Assumes that necessary inspector scroll area layout has already been
        /// created.
        /// </summary>
        private void CreateSceneObjectFields()
        {
            GUIPanel sceneObjectPanel = inspectorLayout.AddPanel();

            sceneObjectPanel.SetHeight(GetTitleBounds().height);

            GUILayoutY sceneObjectLayout = sceneObjectPanel.AddLayoutY();

            sceneObjectLayout.SetPosition(PADDING, PADDING);

            GUIPanel sceneObjectBgPanel = sceneObjectPanel.AddPanel(1);

            GUILayoutX nameLayout = sceneObjectLayout.AddLayoutX();

            soActiveToggle            = new GUIToggle("");
            soActiveToggle.OnToggled += OnSceneObjectActiveStateToggled;
            GUILabel nameLbl = new GUILabel(new LocEdString("Name"), GUIOption.FixedWidth(50));

            soNameInput              = new GUITextBox(false, GUIOption.FlexibleWidth(180));
            soNameInput.Text         = activeSO.Name;
            soNameInput.OnChanged   += OnSceneObjectRename;
            soNameInput.OnConfirmed += OnModifyConfirm;
            soNameInput.OnFocusLost += OnModifyConfirm;

            nameLayout.AddElement(soActiveToggle);
            nameLayout.AddSpace(3);
            nameLayout.AddElement(nameLbl);
            nameLayout.AddElement(soNameInput);
            nameLayout.AddFlexibleSpace();

            GUILayoutX mobilityLayout = sceneObjectLayout.AddLayoutX();
            GUILabel   mobilityLbl    = new GUILabel(new LocEdString("Mobility"), GUIOption.FixedWidth(50));

            soMobility       = new GUIEnumField(typeof(ObjectMobility), "", 0, GUIOption.FixedWidth(85));
            soMobility.Value = (ulong)activeSO.Mobility;
            soMobility.OnSelectionChanged += value => activeSO.Mobility = (ObjectMobility)value;
            mobilityLayout.AddElement(mobilityLbl);
            mobilityLayout.AddElement(soMobility);

            soPrefabLayout = sceneObjectLayout.AddLayoutX();

            soPos = new GUIVector3Field(new LocEdString("Position"), 50);
            sceneObjectLayout.AddElement(soPos);

            soPos.OnChanged   += OnPositionChanged;
            soPos.OnConfirmed += OnModifyConfirm;
            soPos.OnFocusLost += OnModifyConfirm;

            soRot = new GUIVector3Field(new LocEdString("Rotation"), 50);
            sceneObjectLayout.AddElement(soRot);

            soRot.OnChanged   += OnRotationChanged;
            soRot.OnConfirmed += OnModifyConfirm;
            soRot.OnFocusLost += OnModifyConfirm;

            soScale = new GUIVector3Field(new LocEdString("Scale"), 50);
            sceneObjectLayout.AddElement(soScale);

            soScale.OnChanged   += OnScaleChanged;
            soScale.OnConfirmed += OnModifyConfirm;
            soScale.OnFocusLost += OnModifyConfirm;

            sceneObjectLayout.AddFlexibleSpace();

            GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg);

            sceneObjectBgPanel.AddElement(titleBg);
        }
示例#8
0
        /// <inheritoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            GUILayoutX boundsLayout = new GUILayoutX();

            centerField = new GUIVector3Field(new LocEdString("Center"), 50);
            sizeField   = new GUIVector3Field(new LocEdString("Size"), 50);

            layout.AddElement(layoutIndex, boundsLayout);

            boundsLayout.AddElement(new GUILabel(new LocEdString(title), GUIOption.FixedWidth(100)));

            GUILayoutY boundsContent = boundsLayout.AddLayoutY();

            boundsContent.AddElement(centerField);
            boundsContent.AddElement(sizeField);

            centerField.OnValueChanged += x =>
            {
                AABox   bounds = property.GetValue <AABox>();
                Vector3 min    = x - bounds.Size * 0.5f;
                Vector3 max    = x + bounds.Size * 0.5f;

                property.SetValue(new AABox(min, max));
                state |= InspectableState.ModifyInProgress;
            };
            centerField.OnConfirm += x =>
            {
                OnFieldValueConfirm();
                StartUndo("center." + x.ToString());
            };
            centerField.OnComponentFocusChanged += (focus, comp) =>
            {
                if (focus)
                {
                    StartUndo("center." + comp.ToString());
                }
                else
                {
                    OnFieldValueConfirm();
                }
            };

            sizeField.OnValueChanged += x =>
            {
                AABox   bounds = property.GetValue <AABox>();
                Vector3 min    = bounds.Center - x * 0.5f;
                Vector3 max    = bounds.Center + x * 0.5f;

                property.SetValue(new AABox(min, max));
                state |= InspectableState.ModifyInProgress;
            };
            sizeField.OnConfirm += x =>
            {
                OnFieldValueConfirm();
                StartUndo("size." + x.ToString());
            };
            sizeField.OnComponentFocusChanged += (focus, comp) =>
            {
                if (focus)
                {
                    StartUndo("size." + comp.ToString());
                }
                else
                {
                    OnFieldValueConfirm();
                }
            };
        }
示例#9
0
 private static extern void Internal_create3(GUIVector3Field managedInstance, string style);
示例#10
0
 private static extern void Internal_create2(GUIVector3Field managedInstance, LocString labelText, string style);
示例#11
0
 private static extern void Internal_create0(GUIVector3Field managedInstance, ref GUIContent labelContent, string style);
示例#12
0
 private static extern void Internal_CreateInstance(GUIVector3Field instance, ref GUIContent title, int titleWidth,
                                                    string style, GUIOption[] options, bool withTitle);
示例#13
0
        /// <summary>
        /// Creates GUI elements for fields common to all joints.
        /// </summary>
        protected virtual void BuildGUI(Joint joint, bool showOffsets)
        {
            this.showOffsets = showOffsets;

            targetField = new GUIGameObjectField(typeof(Rigidbody), new LocEdString("Target"));
            anchorField = new GUIGameObjectField(typeof(Rigidbody), new LocEdString("Anchor"));

            if (showOffsets)
            {
                targetOffsetField = new GUIVector3Field(new LocEdString("Target offset"));
                anchorOffsetField = new GUIVector3Field(new LocEdString("Anchor offset"));
            }

            breakForceField  = new GUIFloatField(new LocEdString("Break force"));
            breakTorqueField = new GUIFloatField(new LocEdString("Break torque"));
            collisionField   = new GUIToggleField(new LocEdString("Enable collision"));

            targetField.OnChanged += x => { joint.SetBody(JointBody.Target, (Rigidbody)x); MarkAsModified(); ConfirmModify(); };
            anchorField.OnChanged += x => { joint.SetBody(JointBody.Anchor, (Rigidbody)x); MarkAsModified(); ConfirmModify(); };

            if (showOffsets)
            {
                targetOffsetField.OnValueChanged += x =>
                {
                    joint.SetTransform(JointBody.Target, x, joint.GetRotation(JointBody.Target));
                    MarkAsModified();
                };
                targetOffsetField.OnFocusLost += ConfirmModify;
                targetOffsetField.OnConfirm   += x => ConfirmModify();

                anchorOffsetField.OnValueChanged += x =>
                {
                    joint.SetTransform(JointBody.Anchor, x, joint.GetRotation(JointBody.Anchor));
                    MarkAsModified();
                };
                anchorOffsetField.OnFocusLost += ConfirmModify;
                anchorOffsetField.OnConfirm   += x => ConfirmModify();
            }

            breakForceField.OnChanged   += x => { joint.BreakForce = x; MarkAsModified(); };
            breakForceField.OnFocusLost += ConfirmModify;
            breakForceField.OnConfirmed += ConfirmModify;

            breakTorqueField.OnChanged   += x => { joint.BreakTorque = x; MarkAsModified(); };
            breakTorqueField.OnFocusLost += ConfirmModify;
            breakTorqueField.OnConfirmed += ConfirmModify;

            collisionField.OnChanged += x => { joint.EnableCollision = x; MarkAsModified(); ConfirmModify(); };

            Layout.AddElement(targetField);
            if (showOffsets)
            {
                Layout.AddElement(targetOffsetField);
            }
            Layout.AddElement(anchorField);
            if (showOffsets)
            {
                Layout.AddElement(anchorOffsetField);
            }
            Layout.AddElement(breakForceField);
            Layout.AddElement(breakTorqueField);
            Layout.AddElement(collisionField);
        }