예제 #1
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            normalsField           = new GUIToggleField(new LocEdString("Import Normals"));
            tangentsField          = new GUIToggleField(new LocEdString("Import Tangents"));
            skinField              = new GUIToggleField(new LocEdString("Import Skin"));
            blendShapesField       = new GUIToggleField(new LocEdString("Import Blend Shapes"));
            animationField         = new GUIToggleField(new LocEdString("Import Animation"));
            scaleField             = new GUIFloatField(new LocEdString("Scale"));
            cpuCachedField         = new GUIToggleField(new LocEdString("CPU cached"));
            cpuReadableField       = new GUIToggleField(new LocEdString("CPU readable"));
            collisionMeshTypeField = new GUIEnumField(typeof(CollisionMeshType), new LocEdString("Collision mesh"));
            keyFrameReductionField = new GUIToggleField(new LocEdString("Keyframe Reduction"));
            rootMotionField        = new GUIToggleField(new LocEdString("Import root motion"));
            reimportButton         = new GUIButton(new LocEdString("Reimport"));

            normalsField.OnChanged     += x => importOptions.ImportNormals = x;
            tangentsField.OnChanged    += x => importOptions.ImportTangents = x;
            skinField.OnChanged        += x => importOptions.ImportSkin = x;
            blendShapesField.OnChanged += x => importOptions.ImportBlendShapes = x;
            animationField.OnChanged   += x => importOptions.ImportAnimation = x;
            scaleField.OnChanged       += x => importOptions.Scale = x;
            cpuCachedField.OnChanged   += x => importOptions.CPUCached = x;
            cpuReadableField.OnChanged += x => importOptions.CPUReadable = x;
            collisionMeshTypeField.OnSelectionChanged += x => importOptions.CollisionMeshType = (CollisionMeshType)x;
            keyFrameReductionField.OnChanged          += x => importOptions.KeyframeReduction = x;
            rootMotionField.OnChanged += x => importOptions.ImportRootMotion = x;

            reimportButton.OnClick += TriggerReimport;

            Layout.AddElement(normalsField);
            Layout.AddElement(tangentsField);
            Layout.AddElement(skinField);
            Layout.AddElement(blendShapesField);
            Layout.AddElement(animationField);
            Layout.AddElement(scaleField);
            Layout.AddElement(cpuCachedField);
            Layout.AddElement(cpuReadableField);
            Layout.AddElement(collisionMeshTypeField);
            Layout.AddElement(keyFrameReductionField);
            Layout.AddElement(rootMotionField);

            splitInfos = importOptions.AnimationClipSplits;

            animSplitInfoField = GUIArrayField <AnimationSplitInfo, AnimSplitArrayRow> .Create(
                new LocEdString("Animation splits"), splitInfos, Layout);

            animSplitInfoField.OnChanged += x => { splitInfos = x; };
            animSplitInfoField.IsExpanded = Persistent.GetBool("animSplitInfos_Expanded");
            animSplitInfoField.OnExpand  += x => Persistent.SetBool("animSplitInfos_Expanded", x);

            Layout.AddSpace(10);

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
        }
예제 #2
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            LoadResource();

            ScriptCode scriptCode = InspectedObject as ScriptCode;

            if (scriptCode == null)
            {
                return;
            }

            importOptions = GetImportOptions();

            isEditorField.OnChanged += x =>
            {
                importOptions.EditorScript = x;
            };

            GUIPanel  textPanel   = Layout.AddPanel();
            GUILayout textLayoutY = textPanel.AddLayoutY();

            textLayoutY.AddSpace(5);
            GUILayout textLayoutX = textLayoutY.AddLayoutX();

            textLayoutX.AddSpace(5);
            textLayoutX.AddElement(textLabel);
            textLayoutX.AddSpace(5);
            textLayoutY.AddSpace(5);

            GUIPanel textBgPanel = textPanel.AddPanel(1);

            textBgPanel.AddElement(textBg);

            Layout.AddElement(isEditorField);

            GUIButton reimportButton = new GUIButton(new LocEdString("Reimport"));

            reimportButton.OnClick += TriggerReimport;

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddElement(reimportButton);
            reimportButtonLayout.AddFlexibleSpace();
        }
예제 #3
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            fontSizes = GUIArrayField <int, FontSizeArrayRow> .Create(
                new LocEdString("Font sizes"), importOptions.FontSizes, Layout);

            fontSizes.OnChanged += x => importOptions.FontSizes = x;
            fontSizes.IsExpanded = Persistent.GetBool("fontSizes_Expanded");
            fontSizes.OnExpand  += x => Persistent.SetBool("fontSizes_Expanded", x);

            charRanges = GUIArrayField <CharRange, CharRangeArrayRow> .Create(
                new LocEdString("Character ranges"), importOptions.CharRanges, Layout);

            charRanges.OnChanged += x => importOptions.CharRanges = x;
            charRanges.IsExpanded = Persistent.GetBool("charRanges_Expanded");
            charRanges.OnExpand  += x => Persistent.SetBool("charRanges_Expanded", x);

            renderModeField = new GUIEnumField(typeof(FontRenderMode), new LocEdString("Render mode"));
            renderModeField.OnSelectionChanged += x => importOptions.RenderMode = (FontRenderMode)x;

            boldField            = new GUIToggleField(new LocEdString("Bold"));
            boldField.OnChanged += x => importOptions.Bold = x;

            italicField            = new GUIToggleField(new LocEdString("Italic"));
            italicField.OnChanged += x => importOptions.Italic = x;

            dpiField            = new GUIIntField(new LocEdString("DPI"));
            dpiField.OnChanged += x => importOptions.DPI = x;

            reimportButton          = new GUIButton(new LocEdString("Reimport"));
            reimportButton.OnClick += TriggerReimport;

            Layout.AddElement(renderModeField);
            Layout.AddElement(boldField);
            Layout.AddElement(italicField);
            Layout.AddElement(dpiField);
            Layout.AddSpace(10);

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
        }
예제 #4
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            importOptions = GetImportOptions();

            formatField.OnSelectionChanged   += x => importOptions.Format = (AudioFormat)x;
            readModeField.OnSelectionChanged += x => importOptions.ReadMode = (AudioReadMode)x;
            bitDepthField.OnSelectionChanged += x => importOptions.BitDepth = (AudioBitDepth)x;
            is3DField.OnChanged += x => importOptions.Is3D = x;

            reimportButton.OnClick += TriggerReimport;

            Layout.AddElement(formatField);
            Layout.AddElement(readModeField);
            Layout.AddElement(bitDepthField);
            Layout.AddElement(is3DField);
            Layout.AddSpace(10);

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
        }
        /// <summary>
        /// Creates GUI elements for fields specific to the distance joint.
        /// </summary>
        protected void BuildGUI(DistanceJoint joint)
        {
            enableMinLimitField.OnChanged += x =>
            {
                joint.EnableMinDistanceLimit = x;
                MarkAsModified();
                ConfirmModify();

                minLimitField.Active = x;
            };

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

            enableMaxLimitField.OnChanged += x =>
            {
                joint.EnableMaxDistanceLimit = x;
                MarkAsModified();
                ConfirmModify();

                maxLimitField.Active = x;
            };

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

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

            enableSpringField.OnChanged += x =>
            {
                joint.EnableSpring = x;
                MarkAsModified();
                ConfirmModify();

                springLayout.Active = x;
            };

            Layout.AddElement(enableMinLimitField);
            GUILayoutX minLimitLayout = Layout.AddLayoutX();

            {
                minLimitLayout.AddSpace(10);
                minLimitLayout.AddElement(minLimitField);
            }

            Layout.AddElement(enableMaxLimitField);
            GUILayoutX maxLimitLayout = Layout.AddLayoutX();

            {
                maxLimitLayout.AddSpace(10);
                maxLimitLayout.AddElement(maxLimitField);
            }

            Layout.AddElement(toleranceField);
            Layout.AddElement(enableSpringField);
            springLayout = Layout.AddLayoutX();
            {
                springLayout.AddSpace(10);
                springGUI              = new SpringGUI(joint.Spring, springLayout);
                springGUI.OnChanged   += x => { joint.Spring = x; MarkAsModified(); };
                springGUI.OnConfirmed += ConfirmModify;
            }

            minLimitField.Active = joint.EnableMinDistanceLimit;
            maxLimitField.Active = joint.EnableMaxDistanceLimit;
            springLayout.Active  = joint.EnableSpring;

            base.BuildGUI(joint, true);
        }
예제 #6
0
        /// <summary>
        /// Creates GUI elements for fields specific to the spherical joint.
        /// </summary>
        protected void BuildGUI(D6Joint joint)
        {
            for (int i = 0; i < (int)D6JointAxis.Count; i++)
            {
                D6JointAxis axis      = (D6JointAxis)i;
                string      entryName = Enum.GetName(typeof(D6JointAxis), axis);

                motionFields[i] = new GUIEnumField(typeof(D6JointMotion), new LocEdString(entryName));
                motionFields[i].OnSelectionChanged += x =>
                {
                    joint.SetMotion(axis, (D6JointMotion)x);

                    MarkAsModified();
                    ConfirmModify();
                };
            }

            linearLimitFoldout.AcceptsKeyFocus = false;
            linearLimitFoldout.OnToggled      += x =>
            {
                linearLimitLayout.Active = x;
                Persistent.SetBool("linearLimit_Expanded", x);
            };

            twistLimitFoldout.AcceptsKeyFocus = false;
            twistLimitFoldout.OnToggled      += x =>
            {
                twistLimitLayout.Active = x;
                Persistent.SetBool("twistLimit_Expanded", x);
            };

            swingLimitFoldout.AcceptsKeyFocus = false;
            swingLimitFoldout.OnToggled      += x =>
            {
                swingLimitLayout.Active = x;
                Persistent.SetBool("swingLimit_Expanded", x);
            };

            driveFoldout.AcceptsKeyFocus = false;
            driveFoldout.OnToggled      += x =>
            {
                driveLayout.Active = x;
                Persistent.SetBool("drive_Expanded", x);
            };

            drivePositionField.OnChanged   += x => { joint.SetDriveTransform(x, joint.DriveRotation); MarkAsModified(); };
            drivePositionField.OnFocusLost += ConfirmModify;
            drivePositionField.OnConfirmed += ConfirmModify;

            driveRotationField.OnChanged   += x => { joint.SetDriveTransform(joint.DrivePosition, Quaternion.FromEuler(x)); MarkAsModified(); };
            driveRotationField.OnFocusLost += ConfirmModify;
            driveRotationField.OnConfirmed += ConfirmModify;

            driveLinVelocityField.OnChanged   += x => { joint.SetDriveVelocity(x, joint.DriveAngularVelocity); MarkAsModified(); };
            driveLinVelocityField.OnFocusLost += ConfirmModify;
            driveLinVelocityField.OnConfirmed += ConfirmModify;

            driveAngVelocityField.OnChanged   += x => { joint.SetDriveVelocity(joint.DriveLinearVelocity, x); MarkAsModified(); };
            driveAngVelocityField.OnFocusLost += ConfirmModify;
            driveAngVelocityField.OnConfirmed += ConfirmModify;

            for (int i = 0; i < (int)D6JointAxis.Count; i++)
            {
                Layout.AddElement(motionFields[i]);
            }

            Layout.AddElement(linearLimitFoldout);
            linearLimitLayout = Layout.AddLayoutX();
            {
                linearLimitLayout.AddSpace(10);
                GUILayoutY linearLimitContentsLayout = linearLimitLayout.AddLayoutY();
                limitLinearGUI            = new LimitLinearGUI(joint.LimitLinear, linearLimitContentsLayout, Persistent);
                limitLinearGUI.OnChanged += (x, y) =>
                {
                    joint.LimitLinear = x;
                    joint.LimitLinear.SetBase(y);

                    MarkAsModified();
                };
                limitLinearGUI.OnConfirmed += ConfirmModify;
            }

            Layout.AddElement(twistLimitFoldout);
            twistLimitLayout = Layout.AddLayoutX();
            {
                twistLimitLayout.AddSpace(10);
                GUILayoutY twistLimitContentsLayout = twistLimitLayout.AddLayoutY();
                limitTwistGUI            = new LimitAngularRangeGUI(joint.LimitTwist, twistLimitContentsLayout, Persistent);
                limitTwistGUI.OnChanged += (x, y) =>
                {
                    joint.LimitTwist = x;
                    joint.LimitTwist.SetBase(y);

                    MarkAsModified();
                };
                limitTwistGUI.OnConfirmed += ConfirmModify;
            }

            Layout.AddElement(swingLimitFoldout);
            swingLimitLayout = Layout.AddLayoutX();
            {
                swingLimitLayout.AddSpace(10);
                GUILayoutY swingLimitContentsLayout = swingLimitLayout.AddLayoutY();
                limitSwingGUI            = new LimitConeRangeGUI(joint.LimitSwing, swingLimitContentsLayout, Persistent);
                limitSwingGUI.OnChanged += (x, y) =>
                {
                    joint.LimitSwing = x;
                    joint.LimitSwing.SetBase(y);

                    MarkAsModified();
                };
                limitSwingGUI.OnConfirmed += ConfirmModify;
            }

            Layout.AddElement(driveFoldout);
            driveLayout = Layout.AddLayoutX();
            {
                driveLayout.AddSpace(10);
                GUILayoutY driveContentsLayout = driveLayout.AddLayoutY();

                for (int i = 0; i < (int)D6JointDriveType.Count; i++)
                {
                    D6JointDriveType type = (D6JointDriveType)i;

                    drivesGUI[i]              = new D6JointDriveGUI(joint.GetDrive(type), driveContentsLayout);
                    drivesGUI[i].OnChanged   += x => { joint.SetDrive(type, x); MarkAsModified(); };
                    drivesGUI[i].OnConfirmed += ConfirmModify;
                }

                driveContentsLayout.AddElement(drivePositionField);
                driveContentsLayout.AddElement(driveRotationField);
                driveContentsLayout.AddElement(driveLinVelocityField);
                driveContentsLayout.AddElement(driveAngVelocityField);
            }

            linearLimitLayout.Active = Persistent.GetBool("linearLimit_Expanded");
            twistLimitLayout.Active  = Persistent.GetBool("twistLimit_Expanded");
            swingLimitLayout.Active  = Persistent.GetBool("swingLimit_Expanded");
            driveLayout.Active       = Persistent.GetBool("drive_Expanded");

            base.BuildGUI(joint, true);
        }
예제 #7
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            Animation animation = InspectedObject as Animation;

            if (animation == null)
            {
                return;
            }

            animationClipField.OnChanged += x =>
            {
                AnimationClip clip = Resources.Load <AnimationClip>(x.UUID);

                animation.DefaultClip = clip;
                MarkAsModified();
                ConfirmModify();
            };

            wrapModeField.OnSelectionChanged += x =>
            {
                animation.WrapMode = (AnimWrapMode)x;
                MarkAsModified();
                ConfirmModify();
            };

            speedField.OnChanged   += x => { animation.Speed = x; MarkAsModified(); };
            speedField.OnConfirmed += ConfirmModify;
            speedField.OnFocusLost += ConfirmModify;

            cullingField.OnChanged        += x => { animation.Cull = x; MarkAsModified(); ConfirmModify(); };
            overrideBoundsField.OnChanged += x => { animation.UseBounds = x; MarkAsModified(); ConfirmModify(); };
            centerField.OnChanged         += x =>
            {
                AABox   bounds = animation.Bounds;
                Vector3 min    = x - bounds.Size * 0.5f;
                Vector3 max    = x + bounds.Size * 0.5f;

                animation.Bounds = new AABox(min, max);
                MarkAsModified();
            };
            centerField.OnConfirmed += ConfirmModify;
            centerField.OnFocusLost += ConfirmModify;

            sizeField.OnChanged += x =>
            {
                AABox   bounds = animation.Bounds;
                Vector3 min    = bounds.Center - x * 0.5f;
                Vector3 max    = bounds.Center + x * 0.5f;

                animation.Bounds = new AABox(min, max);
                MarkAsModified();
            };
            sizeField.OnConfirmed += ConfirmModify;
            sizeField.OnFocusLost += ConfirmModify;

            Layout.AddElement(animationClipField);
            Layout.AddElement(wrapModeField);
            Layout.AddElement(speedField);
            Layout.AddElement(cullingField);
            Layout.AddElement(overrideBoundsField);

            GUILayoutX boundsLayout = Layout.AddLayoutX();

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

            GUILayoutY boundsContent = boundsLayout.AddLayoutY();

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

            // Morph shapes
            Renderable  renderable  = animation.SceneObject.GetComponent <Renderable>();
            MorphShapes morphShapes = renderable?.Mesh.Value?.MorphShapes;

            if (morphShapes != null)
            {
                GUIToggle morphShapesToggle = new GUIToggle(new LocEdString("Morph shapes"), EditorStyles.Foldout);

                Layout.AddElement(morphShapesToggle);
                GUILayoutY channelsLayout = Layout.AddLayoutY();

                morphShapesToggle.OnToggled += x =>
                {
                    channelsLayout.Active = x;
                    Persistent.SetBool("Channels_Expanded", x);
                };

                channelsLayout.Active = Persistent.GetBool("Channels_Expanded");

                MorphChannel[] channels = morphShapes.Channels;
                for (int i = 0; i < channels.Length; i++)
                {
                    GUILayoutY channelLayout = channelsLayout.AddLayoutY();

                    GUILayoutX channelTitleLayout = channelLayout.AddLayoutX();
                    channelLayout.AddSpace(5);
                    GUILayoutY channelContentLayout = channelLayout.AddLayoutY();

                    string    channelName      = channels[i].Name;
                    GUIToggle channelNameField = new GUIToggle(channelName, EditorStyles.Expand, GUIOption.FlexibleWidth());

                    channelTitleLayout.AddSpace(15); // Indent
                    channelTitleLayout.AddElement(channelNameField);
                    channelTitleLayout.AddFlexibleSpace();

                    channelNameField.OnToggled += x =>
                    {
                        channelContentLayout.Active = x;

                        Persistent.SetBool(channelName + "_Expanded", x);
                    };

                    channelContentLayout.Active = Persistent.GetBool(channelName + "_Expanded");

                    MorphShape[] shapes = channels[i].Shapes;
                    for (int j = 0; j < shapes.Length; j++)
                    {
                        GUILayoutX shapeLayout = channelContentLayout.AddLayoutX();
                        channelContentLayout.AddSpace(5);

                        LocString nameString = new LocString("[{0}]. {1}");
                        nameString.SetParameter(0, j.ToString());
                        nameString.SetParameter(1, shapes[j].Name);
                        GUILabel shapeNameField = new GUILabel(shapes[j].Name);

                        LocString weightString = new LocEdString("Weight: {0}");
                        weightString.SetParameter(0, shapes[j].Weight.ToString());
                        GUILabel weightField = new GUILabel(weightString);

                        shapeLayout.AddSpace(30); // Indent
                        shapeLayout.AddElement(shapeNameField);
                        shapeLayout.AddFlexibleSpace();
                        shapeLayout.AddElement(weightField);
                    }
                }
            }
        }
예제 #8
0
        /// <summary>
        /// Creates GUI elements for fields specific to the hinge joint.
        /// </summary>
        protected void BuildGUI(HingeJoint joint)
        {
            enableLimitField.OnChanged += x =>
            {
                joint.EnableLimit = x;
                MarkAsModified();
                ConfirmModify();

                ToggleLimitFields(x);
            };

            enableDriveField.OnChanged += x =>
            {
                joint.EnableDrive = x;
                MarkAsModified();
                ConfirmModify();

                ToggleDriveFields(x);
            };

            speedField.OnChanged += x =>
            {
                HingeJointDriveData driveData = joint.Drive.Data;
                driveData.speed = x;
                joint.Drive     = new HingeJointDrive(driveData);

                MarkAsModified();
            };
            speedField.OnFocusLost += ConfirmModify;
            speedField.OnConfirmed += ConfirmModify;

            forceLimitField.OnChanged += x =>
            {
                HingeJointDriveData driveData = joint.Drive.Data;
                driveData.forceLimit = x;
                joint.Drive          = new HingeJointDrive(driveData);

                MarkAsModified();
            };
            forceLimitField.OnFocusLost += ConfirmModify;
            forceLimitField.OnConfirmed += ConfirmModify;

            gearRatioField.OnChanged += x =>
            {
                HingeJointDriveData driveData = joint.Drive.Data;
                driveData.gearRatio = x;
                joint.Drive         = new HingeJointDrive(driveData);

                MarkAsModified();
            };
            gearRatioField.OnFocusLost += ConfirmModify;
            gearRatioField.OnConfirmed += ConfirmModify;

            freeSpinField.OnChanged += x =>
            {
                HingeJointDriveData driveData = joint.Drive.Data;
                driveData.freeSpin = x;
                joint.Drive        = new HingeJointDrive(driveData);

                MarkAsModified();
                ConfirmModify();
            };

            Layout.AddElement(enableLimitField);
            limitLayout = Layout.AddLayoutX();
            {
                limitLayout.AddSpace(10);

                GUILayoutY limitContentsLayout = limitLayout.AddLayoutY();
                limitGUI            = new LimitAngularRangeGUI(joint.Limit, limitContentsLayout, Persistent);
                limitGUI.OnChanged += (x, y) =>
                {
                    joint.Limit = new LimitAngularRange(x, y);

                    MarkAsModified();
                };
                limitGUI.OnConfirmed += ConfirmModify;
            }

            Layout.AddElement(enableDriveField);
            driveLayout = Layout.AddLayoutX();
            {
                driveLayout.AddSpace(10);

                GUILayoutY driveContentsLayout = driveLayout.AddLayoutY();
                driveContentsLayout.AddElement(speedField);
                driveContentsLayout.AddElement(forceLimitField);
                driveContentsLayout.AddElement(gearRatioField);
                driveContentsLayout.AddElement(freeSpinField);
            }

            ToggleLimitFields(joint.EnableLimit);
            ToggleDriveFields(joint.EnableDrive);

            base.BuildGUI(joint, true);
        }
예제 #9
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            Animation animation = InspectedObject as Animation;

            if (animation == null)
            {
                return;
            }

            animationClipField.OnChanged += x =>
            {
                AnimationClip clip = Resources.Load <AnimationClip>(x);

                animation.DefaultClip = clip;
                MarkAsModified();
                ConfirmModify();
            };

            wrapModeField.OnSelectionChanged += x =>
            {
                animation.WrapMode = (AnimWrapMode)x;
                MarkAsModified();
                ConfirmModify();
            };

            speedField.OnChanged   += x => { animation.Speed = x; MarkAsModified(); };
            speedField.OnConfirmed += ConfirmModify;
            speedField.OnFocusLost += ConfirmModify;

            cullingField.OnChanged        += x => { animation.Cull = x; MarkAsModified(); ConfirmModify(); };
            overrideBoundsField.OnChanged += x => { animation.UseBounds = x; MarkAsModified(); ConfirmModify(); };
            centerField.OnChanged         += x =>
            {
                AABox   bounds = animation.Bounds;
                Vector3 min    = x - bounds.Size * 0.5f;
                Vector3 max    = x + bounds.Size * 0.5f;

                animation.Bounds = new AABox(min, max);
                MarkAsModified();
            };
            centerField.OnConfirmed += ConfirmModify;
            centerField.OnFocusLost += ConfirmModify;

            sizeField.OnChanged += x =>
            {
                AABox   bounds = animation.Bounds;
                Vector3 min    = bounds.Center - x * 0.5f;
                Vector3 max    = bounds.Center + x * 0.5f;

                animation.Bounds = new AABox(min, max);
                MarkAsModified();
            };
            sizeField.OnConfirmed += ConfirmModify;
            sizeField.OnFocusLost += ConfirmModify;

            Layout.AddElement(animationClipField);
            Layout.AddElement(wrapModeField);
            Layout.AddElement(speedField);
            Layout.AddElement(cullingField);
            Layout.AddElement(overrideBoundsField);

            GUILayoutX boundsLayout = Layout.AddLayoutX();

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

            GUILayoutY boundsContent = boundsLayout.AddLayoutY();

            boundsContent.AddElement(centerField);
            boundsContent.AddElement(sizeField);
        }
예제 #10
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            if (InspectedObject != null)
            {
                Camera camera = (Camera)InspectedObject;

                projectionTypeField.OnSelectionChanged += x =>
                {
                    camera.ProjectionType = (ProjectionType)x;
                    MarkAsModified();
                    ConfirmModify();
                    ToggleTypeSpecificFields((ProjectionType)x);
                };

                fieldOfView.OnChanged   += x => { camera.FieldOfView = (Degree)x; MarkAsModified(); };
                fieldOfView.OnFocusLost += ConfirmModify;

                orthoHeight.OnChanged   += x => { camera.OrthoHeight = x; MarkAsModified(); };
                orthoHeight.OnConfirmed += ConfirmModify;
                orthoHeight.OnFocusLost += ConfirmModify;

                aspectField.OnChanged   += x => { camera.AspectRatio = x; MarkAsModified(); };
                aspectField.OnConfirmed += ConfirmModify;
                aspectField.OnFocusLost += ConfirmModify;

                nearPlaneField.OnChanged   += x => { camera.NearClipPlane = x; MarkAsModified(); };
                nearPlaneField.OnConfirmed += ConfirmModify;
                nearPlaneField.OnFocusLost += ConfirmModify;

                farPlaneField.OnChanged   += x => { camera.FarClipPlane = x; MarkAsModified(); };
                farPlaneField.OnConfirmed += ConfirmModify;
                farPlaneField.OnFocusLost += ConfirmModify;

                viewportXField.OnChanged += x =>
                {
                    Rect2 rect = camera.Viewport.Area;
                    rect.x = x;
                    camera.Viewport.Area = rect;

                    MarkAsModified();
                };
                viewportXField.OnConfirmed += ConfirmModify;
                viewportXField.OnFocusLost += ConfirmModify;

                viewportYField.OnChanged += x =>
                {
                    Rect2 rect = camera.Viewport.Area;
                    rect.y = x;
                    camera.Viewport.Area = rect;

                    MarkAsModified();
                };
                viewportYField.OnConfirmed += ConfirmModify;
                viewportYField.OnFocusLost += ConfirmModify;

                viewportWidthField.OnChanged += x =>
                {
                    Rect2 rect = camera.Viewport.Area;
                    rect.width           = x;
                    camera.Viewport.Area = rect;

                    MarkAsModified();
                };
                viewportWidthField.OnConfirmed += ConfirmModify;
                viewportWidthField.OnFocusLost += ConfirmModify;

                viewportHeightField.OnChanged += x =>
                {
                    Rect2 rect = camera.Viewport.Area;
                    rect.height          = x;
                    camera.Viewport.Area = rect;

                    MarkAsModified();
                };
                viewportHeightField.OnConfirmed += ConfirmModify;
                viewportHeightField.OnFocusLost += ConfirmModify;

                clearFlagsFields.OnSelectionChanged += x =>
                {
                    camera.Viewport.ClearFlags = (ClearFlags)x;
                    MarkAsModified();
                    ConfirmModify();
                };

                clearStencilField.OnChanged   += x => { camera.Viewport.ClearStencil = (ushort)x; };
                clearStencilField.OnConfirmed += ConfirmModify;
                clearStencilField.OnFocusLost += ConfirmModify;

                clearDepthField.OnChanged   += x => { camera.Viewport.ClearDepth = x; };
                clearDepthField.OnConfirmed += ConfirmModify;
                clearDepthField.OnFocusLost += ConfirmModify;

                clearColorField.OnChanged += x =>
                {
                    camera.Viewport.ClearColor = x;
                    MarkAsModified();
                    ConfirmModify();
                };

                priorityField.OnChanged   += x => { camera.Priority = x; MarkAsModified(); };
                priorityField.OnConfirmed += ConfirmModify;
                priorityField.OnFocusLost += ConfirmModify;

                layersField.OnSelectionChanged += x =>
                {
                    ulong  layers = 0;
                    bool[] states = layersField.States;
                    for (int i = 0; i < states.Length; i++)
                    {
                        layers |= states[i] ? Layers.Values[i] : 0;
                    }

                    layersValue   = layers;
                    camera.Layers = layers;

                    MarkAsModified();
                    ConfirmModify();
                };

                mainField.OnChanged += x =>
                {
                    camera.Main = x;
                    MarkAsModified();
                    ConfirmModify();
                };

                Layout.AddElement(projectionTypeField);
                Layout.AddElement(fieldOfView);
                Layout.AddElement(orthoHeight);
                Layout.AddElement(aspectField);
                Layout.AddElement(nearPlaneField);
                Layout.AddElement(farPlaneField);
                GUILayoutX viewportTopLayout = Layout.AddLayoutX();
                viewportTopLayout.AddElement(new GUILabel(new LocEdString("Viewport"), GUIOption.FixedWidth(100)));
                GUILayoutY viewportContentLayout = viewportTopLayout.AddLayoutY();

                GUILayoutX viewportTopRow = viewportContentLayout.AddLayoutX();
                viewportTopRow.AddElement(viewportXField);
                viewportTopRow.AddElement(viewportWidthField);

                GUILayoutX viewportBotRow = viewportContentLayout.AddLayoutX();
                viewportBotRow.AddElement(viewportYField);
                viewportBotRow.AddElement(viewportHeightField);

                Layout.AddElement(clearFlagsFields);
                Layout.AddElement(clearColorField);
                Layout.AddElement(clearDepthField);
                Layout.AddElement(clearStencilField);
                Layout.AddElement(priorityField);
                Layout.AddElement(layersField);
                Layout.AddElement(mainField);

                renderSettingsFoldout.OnToggled += x =>
                {
                    Persistent.SetBool("renderSettings_Expanded", x);
                    renderSettingsLayout.Active = x;
                };
                renderSettingsFoldout.AcceptsKeyFocus = false;
                Layout.AddElement(renderSettingsFoldout);

                renderSettingsLayout = Layout.AddLayoutX();
                {
                    renderSettingsLayout.AddSpace(10);

                    GUILayoutY contentsLayout = renderSettingsLayout.AddLayoutY();
                    renderSettingsGUI = new InspectorFieldDrawer(new InspectableContext(Persistent, camera), contentsLayout);
                    renderSettingsGUI.AddDefault(camera.RenderSettings);
                }

                ToggleTypeSpecificFields(camera.ProjectionType);
                renderSettingsLayout.Active = Persistent.GetBool("renderSettings_Expanded");
            }
        }
예제 #11
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            Layout.Clear();

            LightProbeVolume lpv = InspectedObject as LightProbeVolume;

            if (lpv == null)
            {
                return;
            }

            // Set up callbacks
            addProbeButton.OnClick += () =>
            {
                StartUndo();
                lpv.AddProbe(Vector3.Zero);
                EndUndo();

                MarkAsModified();
                ConfirmModify();
            };

            removeProbeButton.OnClick += () =>
            {
                if (LightProbeVolumeNodeHandles.SelectedNode != uint.MaxValue)
                {
                    StartUndo();
                    lpv.RemoveProbe((int)LightProbeVolumeNodeHandles.SelectedNode);
                    EndUndo();

                    MarkAsModified();
                    ConfirmModify();
                }
            };

            positionField.OnConfirm += x =>
            {
                AABox   gridVolume = lpv.GridVolume;
                Vector3 extents    = (gridVolume.Maximum - gridVolume.Minimum) * 0.5f;

                Vector3 min = positionField.Value - extents;
                Vector3 max = positionField.Value + extents;

                Vector3I cellCount = lpv.CellCount;

                gridVolume = new AABox(min, max);

                StartUndo();
                lpv.Resize(gridVolume, cellCount);
                EndUndo();

                MarkAsModified();
                ConfirmModify();
            };

            sizeField.OnConfirm += x =>
            {
                AABox gridVolume = lpv.GridVolume;

                Vector3 min = gridVolume.Minimum;
                Vector3 max = min + sizeField.Value;

                Vector3I cellCount = lpv.CellCount;

                gridVolume = new AABox(min, max);

                StartUndo();
                lpv.Resize(gridVolume, cellCount);
                EndUndo();

                MarkAsModified();
                ConfirmModify();
            };

            densityField.OnConfirm += x =>
            {
                AABox gridVolume = lpv.GridVolume;

                Vector3  density   = densityField.Value;
                Vector3I cellCount = new Vector3I((int)density.x, (int)density.y, (int)density.y);

                StartUndo();
                lpv.Resize(gridVolume, cellCount);
                EndUndo();

                MarkAsModified();
                ConfirmModify();
            };

            resetToGridButton.OnClick += () =>
            {
                StartUndo();
                lpv.Reset();
                EndUndo();

                MarkAsModified();
                ConfirmModify();
            };

            clipOuterButton.OnClick += () =>
            {
                StartUndo();
                lpv.Clip();
                EndUndo();

                MarkAsModified();
                ConfirmModify();
            };

            renderButton.OnClick += () =>
            {
                lpv.RenderProbes();

                MarkAsModified();
                ConfirmModify();
            };

            // Set up layout
            Layout.AddElement(manualLabel);
            GUILayout manualLayout = Layout.AddLayoutX();

            manualLayout.AddElement(addProbeButton);
            manualLayout.AddElement(removeProbeButton);

            Layout.AddSpace(10);

            Layout.AddElement(uniformLabel);
            Layout.AddElement(positionField);
            Layout.AddElement(sizeField);
            Layout.AddElement(densityField);

            Layout.AddSpace(5);

            GUILayout uniformLayout = Layout.AddLayoutX();

            uniformLayout.AddElement(resetToGridButton);
            uniformLayout.AddElement(clipOuterButton);

            Layout.AddSpace(10);

            Layout.AddElement(renderButton);
        }
예제 #12
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            if (InspectedObject != null)
            {
                Camera camera = (Camera)InspectedObject;

                projectionTypeField.OnSelectionChanged += x =>
                {
                    camera.ProjectionType = (ProjectionType)x;
                    MarkAsModified();
                    ConfirmModify();
                    ToggleTypeSpecificFields((ProjectionType)x);
                };

                fieldOfView.OnChanged   += x => { camera.FieldOfView = (Degree)x; MarkAsModified(); };
                fieldOfView.OnFocusLost += ConfirmModify;

                orthoHeight.OnChanged   += x => { camera.OrthoHeight = x; MarkAsModified(); };
                orthoHeight.OnConfirmed += ConfirmModify;
                orthoHeight.OnFocusLost += ConfirmModify;

                aspectField.OnChanged   += x => { camera.AspectRatio = x; MarkAsModified(); };
                aspectField.OnConfirmed += ConfirmModify;
                aspectField.OnFocusLost += ConfirmModify;

                nearPlaneField.OnChanged   += x => { camera.NearClipPlane = x; MarkAsModified(); };
                nearPlaneField.OnConfirmed += ConfirmModify;
                nearPlaneField.OnFocusLost += ConfirmModify;

                farPlaneField.OnChanged   += x => { camera.FarClipPlane = x; MarkAsModified(); };
                farPlaneField.OnConfirmed += ConfirmModify;
                farPlaneField.OnFocusLost += ConfirmModify;

                viewportXField.OnChanged += x =>
                {
                    Rect2 rect = camera.ViewportRect;
                    rect.x = x;
                    camera.ViewportRect = rect;

                    MarkAsModified();
                };
                viewportXField.OnConfirmed += ConfirmModify;
                viewportXField.OnFocusLost += ConfirmModify;

                viewportYField.OnChanged += x =>
                {
                    Rect2 rect = camera.ViewportRect;
                    rect.y = x;
                    camera.ViewportRect = rect;

                    MarkAsModified();
                };
                viewportYField.OnConfirmed += ConfirmModify;
                viewportYField.OnFocusLost += ConfirmModify;

                viewportWidthField.OnChanged += x =>
                {
                    Rect2 rect = camera.ViewportRect;
                    rect.width          = x;
                    camera.ViewportRect = rect;

                    MarkAsModified();
                };
                viewportWidthField.OnConfirmed += ConfirmModify;
                viewportWidthField.OnFocusLost += ConfirmModify;

                viewportHeightField.OnChanged += x =>
                {
                    Rect2 rect = camera.ViewportRect;
                    rect.height         = x;
                    camera.ViewportRect = rect;

                    MarkAsModified();
                };
                viewportHeightField.OnConfirmed += ConfirmModify;
                viewportHeightField.OnFocusLost += ConfirmModify;

                clearFlagsFields.OnSelectionChanged += x =>
                {
                    camera.ClearFlags = (ClearFlags)x;
                    MarkAsModified();
                    ConfirmModify();
                };

                clearStencilField.OnChanged   += x => { camera.ClearStencil = (ushort)x; };
                clearStencilField.OnConfirmed += ConfirmModify;
                clearStencilField.OnFocusLost += ConfirmModify;

                clearDepthField.OnChanged   += x => { camera.ClearDepth = x; };
                clearDepthField.OnConfirmed += ConfirmModify;
                clearDepthField.OnFocusLost += ConfirmModify;

                clearColorField.OnChanged += x =>
                {
                    camera.ClearColor = x;
                    MarkAsModified();
                    ConfirmModify();
                };

                priorityField.OnChanged   += x => { camera.Priority = x; MarkAsModified(); };
                priorityField.OnConfirmed += ConfirmModify;
                priorityField.OnFocusLost += ConfirmModify;

                layersField.OnSelectionChanged += x =>
                {
                    ulong  layers = 0;
                    bool[] states = layersField.States;
                    for (int i = 0; i < states.Length; i++)
                    {
                        layers |= states[i] ? Layers.Values[i] : 0;
                    }

                    layersValue   = layers;
                    camera.Layers = layers;

                    MarkAsModified();
                    ConfirmModify();
                };

                mainField.OnChanged += x =>
                {
                    camera.Main = x;
                    MarkAsModified();
                    ConfirmModify();
                };

                hdrField.OnChanged += x =>
                {
                    camera.HDR = x;
                    MarkAsModified();
                    ConfirmModify();
                };

                skyboxField.OnChanged += x =>
                {
                    Texture skyboxTex = Resources.Load <Texture>(x);

                    camera.Skybox = skyboxTex as TextureCube;
                    MarkAsModified();
                    ConfirmModify();
                };

                Layout.AddElement(projectionTypeField);
                Layout.AddElement(fieldOfView);
                Layout.AddElement(orthoHeight);
                Layout.AddElement(aspectField);
                Layout.AddElement(nearPlaneField);
                Layout.AddElement(farPlaneField);
                GUILayoutX viewportTopLayout = Layout.AddLayoutX();
                viewportTopLayout.AddElement(new GUILabel(new LocEdString("Viewport"), GUIOption.FixedWidth(100)));
                GUILayoutY viewportContentLayout = viewportTopLayout.AddLayoutY();

                GUILayoutX viewportTopRow = viewportContentLayout.AddLayoutX();
                viewportTopRow.AddElement(viewportXField);
                viewportTopRow.AddElement(viewportWidthField);

                GUILayoutX viewportBotRow = viewportContentLayout.AddLayoutX();
                viewportBotRow.AddElement(viewportYField);
                viewportBotRow.AddElement(viewportHeightField);

                Layout.AddElement(clearFlagsFields);
                Layout.AddElement(clearColorField);
                Layout.AddElement(clearDepthField);
                Layout.AddElement(clearStencilField);
                Layout.AddElement(priorityField);
                Layout.AddElement(layersField);
                Layout.AddElement(mainField);
                Layout.AddElement(hdrField);
                Layout.AddElement(skyboxField);

                postProcessFoldout.OnToggled += x =>
                {
                    Persistent.SetBool("postProcess_Expanded", x);
                    postProcessLayout.Active = x;
                };
                Layout.AddElement(postProcessFoldout);

                postProcessLayout = Layout.AddLayoutX();
                {
                    postProcessLayout.AddSpace(10);

                    GUILayoutY contentsLayout = postProcessLayout.AddLayoutY();
                    postProcessGUI              = new PostProcessSettingsGUI(camera.PostProcess, contentsLayout, Persistent);
                    postProcessGUI.OnChanged   += x => { camera.PostProcess = x; MarkAsModified(); };
                    postProcessGUI.OnConfirmed += ConfirmModify;
                }

                ToggleTypeSpecificFields(camera.ProjectionType);
                postProcessLayout.Active = Persistent.GetBool("postProcess_Expanded");
            }
        }
예제 #13
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            if (InspectedObject != null)
            {
                Camera camera = (Camera)InspectedObject;

                projectionTypeField.OnSelectionChanged += x =>
                {
                    camera.ProjectionType = (ProjectionType)x;
                    MarkAsModified();
                    ConfirmModify();
                    ToggleTypeSpecificFields((ProjectionType)x);
                };

                fieldOfView.OnChanged   += x => { camera.FieldOfView = x; MarkAsModified(); };
                fieldOfView.OnFocusLost += ConfirmModify;

                orthoHeight.OnChanged   += x => { camera.OrthoHeight = x; MarkAsModified(); };
                orthoHeight.OnConfirmed += ConfirmModify;
                orthoHeight.OnFocusLost += ConfirmModify;

                aspectField.OnChanged   += x => { camera.AspectRatio = x; MarkAsModified(); };
                aspectField.OnConfirmed += ConfirmModify;
                aspectField.OnFocusLost += ConfirmModify;

                nearPlaneField.OnChanged   += x => { camera.NearClipPlane = x; MarkAsModified(); };
                nearPlaneField.OnConfirmed += ConfirmModify;
                nearPlaneField.OnFocusLost += ConfirmModify;

                farPlaneField.OnChanged   += x => { camera.FarClipPlane = x; MarkAsModified(); };
                farPlaneField.OnConfirmed += ConfirmModify;
                farPlaneField.OnFocusLost += ConfirmModify;

                viewportXField.OnChanged += x =>
                {
                    Rect2 rect = camera.ViewportRect;
                    rect.x = x;
                    camera.ViewportRect = rect;

                    MarkAsModified();
                };
                viewportXField.OnConfirmed += ConfirmModify;
                viewportXField.OnFocusLost += ConfirmModify;

                viewportYField.OnChanged += x =>
                {
                    Rect2 rect = camera.ViewportRect;
                    rect.y = x;
                    camera.ViewportRect = rect;

                    MarkAsModified();
                };
                viewportYField.OnConfirmed += ConfirmModify;
                viewportYField.OnFocusLost += ConfirmModify;

                viewportWidthField.OnChanged += x =>
                {
                    Rect2 rect = camera.ViewportRect;
                    rect.width          = x;
                    camera.ViewportRect = rect;

                    MarkAsModified();
                };
                viewportWidthField.OnConfirmed += ConfirmModify;
                viewportWidthField.OnFocusLost += ConfirmModify;

                viewportHeightField.OnChanged += x =>
                {
                    Rect2 rect = camera.ViewportRect;
                    rect.height         = x;
                    camera.ViewportRect = rect;

                    MarkAsModified();
                };
                viewportHeightField.OnConfirmed += ConfirmModify;
                viewportHeightField.OnFocusLost += ConfirmModify;

                clearFlagsFields.OnSelectionChanged += x =>
                {
                    camera.ClearFlags = (ClearFlags)x;
                    MarkAsModified();
                    ConfirmModify();
                };

                clearStencilField.OnChanged   += x => { camera.ClearStencil = (ushort)x; };
                clearStencilField.OnConfirmed += ConfirmModify;
                clearStencilField.OnFocusLost += ConfirmModify;

                clearDepthField.OnChanged   += x => { camera.ClearDepth = x; };
                clearDepthField.OnConfirmed += ConfirmModify;
                clearDepthField.OnFocusLost += ConfirmModify;

                clearColorField.OnChanged += x =>
                {
                    camera.ClearColor = x;
                    MarkAsModified();
                    ConfirmModify();
                };

                priorityField.OnChanged   += x => { camera.Priority = x; MarkAsModified(); };
                priorityField.OnConfirmed += ConfirmModify;
                priorityField.OnFocusLost += ConfirmModify;

                layersField.OnSelectionChanged += x =>
                {
                    ulong  layers = 0;
                    bool[] states = layersField.States;
                    for (int i = 0; i < states.Length; i++)
                    {
                        layers |= states[i] ? Layers.Values[i] : 0;
                    }

                    layersValue   = layers;
                    camera.Layers = layers;

                    MarkAsModified();
                    ConfirmModify();
                };

                mainField.OnChanged += x =>
                {
                    camera.Main = x;
                    MarkAsModified();
                    ConfirmModify();
                };

                Layout.AddElement(projectionTypeField);
                Layout.AddElement(fieldOfView);
                Layout.AddElement(orthoHeight);
                Layout.AddElement(aspectField);
                Layout.AddElement(nearPlaneField);
                Layout.AddElement(farPlaneField);
                GUILayoutX viewportTopLayout = Layout.AddLayoutX();
                viewportTopLayout.AddElement(new GUILabel(new LocEdString("Viewport"), GUIOption.FixedWidth(100)));
                GUILayoutY viewportContentLayout = viewportTopLayout.AddLayoutY();

                GUILayoutX viewportTopRow = viewportContentLayout.AddLayoutX();
                viewportTopRow.AddElement(viewportXField);
                viewportTopRow.AddElement(viewportWidthField);

                GUILayoutX viewportBotRow = viewportContentLayout.AddLayoutX();
                viewportBotRow.AddElement(viewportYField);
                viewportBotRow.AddElement(viewportHeightField);

                Layout.AddElement(clearFlagsFields);
                Layout.AddElement(clearColorField);
                Layout.AddElement(clearDepthField);
                Layout.AddElement(clearStencilField);
                Layout.AddElement(priorityField);
                Layout.AddElement(layersField);
                Layout.AddElement(mainField);

                ToggleTypeSpecificFields(camera.ProjectionType);
            }
        }