Пример #1
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            GUIWidget guiWidget = InspectedObject as GUIWidget;

            if (guiWidget == null)
            {
                return;
            }

            skinField   = new GUIResourceField(typeof(GUISkin), new LocEdString("Skin"));
            cameraField = new GUIGameObjectField(typeof(Camera), new LocEdString("Camera"));

            skinField.OnChanged += x =>
            {
                GUISkin skin = Resources.Load <GUISkin>(x);
                guiWidget.Skin = skin;

                MarkAsModified();
                ConfirmModify();
            };

            cameraField.OnChanged += x =>
            {
                guiWidget.Camera = x as Camera;

                MarkAsModified();
                ConfirmModify();
            };

            Layout.AddElement(skinField);
            Layout.AddElement(cameraField);
        }
Пример #2
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            GUIWidget guiWidget = InspectedObject as GUIWidget;
            if (guiWidget == null)
                return;

            skinField = new GUIResourceField(typeof(GUISkin), new LocEdString("Skin"));
            cameraField = new GUIGameObjectField(typeof (Camera), new LocEdString("Camera"));

            skinField.OnChanged += x =>
            {
                GUISkin skin = Resources.Load<GUISkin>(x);
                guiWidget.Skin = skin;

                MarkAsModified();
                ConfirmModify();
            };

            cameraField.OnChanged += x =>
            {
                guiWidget.Camera = x as Camera;

                MarkAsModified();
                ConfirmModify();
            };

            Layout.AddElement(skinField);
            Layout.AddElement(cameraField);
        }
        /// <inheritoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            if (property != null)
            {
                guiField            = new GUIGameObjectField(property.InternalType, new GUIContent(title));
                guiField.OnChanged += OnFieldValueChanged;

                layout.AddElement(layoutIndex, guiField);
            }
        }
        /// <inheritoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            if (property != null)
            {
                guiField = new GUIGameObjectField(property.InternalType, new GUIContent(title));
                guiField.OnChanged += OnFieldValueChanged;

                layout.AddElement(layoutIndex, guiField);
            }
        }
Пример #5
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.SetRigidbody(JointBody.Target, (Rigidbody)x); MarkAsModified(); ConfirmModify(); };
            anchorField.OnChanged += x => { joint.SetRigidbody(JointBody.Anchor, (Rigidbody)x); MarkAsModified(); ConfirmModify(); };

            if (showOffsets)
            {
                targetOffsetField.OnChanged   += x => { joint.SetPosition(JointBody.Target, x); MarkAsModified(); };
                targetOffsetField.OnFocusLost += ConfirmModify;
                targetOffsetField.OnConfirmed += ConfirmModify;

                anchorOffsetField.OnChanged   += x => { joint.SetPosition(JointBody.Anchor, x); MarkAsModified(); };
                anchorOffsetField.OnFocusLost += ConfirmModify;
                anchorOffsetField.OnConfirmed += 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);
        }
Пример #6
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.SetRigidbody(JointBody.Target, (Rigidbody)x); MarkAsModified(); ConfirmModify(); };
            anchorField.OnChanged += x => { joint.SetRigidbody(JointBody.Anchor, (Rigidbody)x); MarkAsModified(); ConfirmModify(); };

            if(showOffsets)
            {
                targetOffsetField.OnChanged += x => { joint.SetPosition(JointBody.Target, x); MarkAsModified(); };
                targetOffsetField.OnFocusLost += ConfirmModify;
                targetOffsetField.OnConfirmed += ConfirmModify;

                anchorOffsetField.OnChanged += x => { joint.SetPosition(JointBody.Anchor, x); MarkAsModified(); };
                anchorOffsetField.OnFocusLost += ConfirmModify;
                anchorOffsetField.OnConfirmed += 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);
        }
Пример #7
0
 private static extern void Internal_CreateInstance(GUIGameObjectField instance, Type type, ref GUIContent title,
                                                    int titleWidth, string style, GUIOption[] options, bool withTitle);
Пример #8
0
 private static extern void Internal_CreateInstance(GUIGameObjectField instance, Type type, GUIContent title, int titleWidth,
     string style, GUIOption[] options, bool withTitle);