Esempio n. 1
0
        protected virtual void Draw(TSerialized serialized, Editor owner)
        {
            HDProbeUI.Drawer <TProvider> .DrawToolbars(serialized, owner);

            EditorGUI.BeginChangeCheck();
            showChromeGizmo = EditorGUILayout.Toggle(EditorGUIUtility.TrTextContent("Show Chrome Gizmo"), showChromeGizmo);
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }
            HDProbeUI.Drawer <TProvider> .DrawPrimarySettings(serialized, owner);

            //note: cannot use 'using CED = something' due to templated type passed.
            CoreEditorDrawer <TSerialized> .Group(
                CoreEditorDrawer <TSerialized> .FoldoutGroup(HDProbeUI.k_ProxySettingsHeader, HDProbeUI.Expandable.Projection, HDProbeUI.k_ExpandedState,
                                                             HDProbeUI.Drawer <TProvider> .DrawProjectionSettings),
                CoreEditorDrawer <TSerialized> .AdvancedFoldoutGroup(HDProbeUI.k_InfluenceVolumeHeader, HDProbeUI.Expandable.Influence, HDProbeUI.k_ExpandedState,
                                                                     (s, o) => s.GetEditorOnlyData(SerializedHDProbe.EditorOnlyData.InfluenceVolumeIsAdvanced),
                                                                     (s, o) =>
            {
                InfluenceVolumeUI.SetInfluenceAdvancedControlSwitch(s.probeSettings.influence, o, advancedControl: !s.GetEditorOnlyData(SerializedHDProbe.EditorOnlyData.InfluenceVolumeIsAdvanced));
                s.ToggleEditorOnlyData(SerializedHDProbe.EditorOnlyData.InfluenceVolumeIsAdvanced);
            },
                                                                     CoreEditorDrawer <TSerialized> .Group(
                                                                         HDProbeUI.Drawer <TProvider> .DrawInfluenceSettings, //handle both advanced control and normal control
                                                                         HDProbeUI.Drawer_DifferentShapeError
                                                                         ),
                                                                     CoreEditorDrawer <TSerialized> .noop
                                                                     ),
                CoreEditorDrawer <TSerialized> .AdvancedFoldoutGroup(HDProbeUI.k_CaptureSettingsHeader, HDProbeUI.Expandable.Capture, HDProbeUI.k_ExpandedState,
                                                                     (s, o) => s.GetEditorOnlyData(SerializedHDProbe.EditorOnlyData.CaptureSettingsIsAdvanced),
                                                                     (s, o) => s.ToggleEditorOnlyData(SerializedHDProbe.EditorOnlyData.CaptureSettingsIsAdvanced),
                                                                     CoreEditorDrawer <TSerialized> .Group(
                                                                         DrawAdditionalCaptureSettings,
                                                                         HDProbeUI.Drawer <TProvider> .DrawCaptureSettings
                                                                         ),
                                                                     HDProbeUI.Drawer <TProvider> .DrawAdvancedCaptureSettings
                                                                     ),
                CoreEditorDrawer <TSerialized> .AdvancedFoldoutGroup(HDProbeUI.k_CustomSettingsHeader, HDProbeUI.Expandable.Custom, HDProbeUI.k_ExpandedState,
                                                                     (s, o) => s.GetEditorOnlyData(SerializedHDProbe.EditorOnlyData.CustomSettingsIsAdvanced),
                                                                     (s, o) => s.ToggleEditorOnlyData(SerializedHDProbe.EditorOnlyData.CustomSettingsIsAdvanced),
                                                                     HDProbeUI.Drawer <TProvider> .DrawCustomSettings,
                                                                     HDProbeUI.Drawer <TProvider> .DrawAdvancedCustomSettings),
                CoreEditorDrawer <TSerialized> .Group(HDProbeUI.Drawer <TProvider> .DrawBakeButton)
                ).Draw(serialized, owner);
        }
        static void DrawSelectedGizmo(PlanarReflectionProbe probe, GizmoType gizmoType)
        {
            var e = (PlanarReflectionProbeEditor)GetEditorFor(probe);

            if (e == null)
            {
                return;
            }

            var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one);

            InfluenceVolumeUI.DrawGizmos(
                probe.influenceVolume,
                mat,
                InfluenceVolumeUI.HandleType.None,
                InfluenceVolumeUI.HandleType.Base | InfluenceVolumeUI.HandleType.Influence
                );

            if (e.showChromeGizmo)
            {
                DrawCapturePositionGizmo(probe);
            }
        }
        static void DrawSelectedGizmo(ReflectionProbe reflectionProbe, GizmoType gizmoType)
        {
            var e = (HDReflectionProbeEditor)GetEditorFor(reflectionProbe);

            if (e == null)
            {
                return;
            }

            var mat     = Matrix4x4.TRS(reflectionProbe.transform.position, reflectionProbe.transform.rotation, Vector3.one);
            var hdprobe = reflectionProbe.GetComponent <HDAdditionalReflectionData>();

            InfluenceVolumeUI.DrawGizmos(
                hdprobe.influenceVolume,
                mat,
                InfluenceVolumeUI.HandleType.None,
                InfluenceVolumeUI.HandleType.Base | InfluenceVolumeUI.HandleType.Influence
                );

            if (e.showChromeGizmo)
            {
                Gizmos_CapturePoint(reflectionProbe);
            }
        }
            public static void DrawInfluenceSettings(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                InfluenceVolumeUI.Draw <TProvider>(serialized.probeSettings.influence, owner);
            }
        internal static void DrawHandles(SerializedHDProbe serialized, Editor owner)
        {
            var probe = serialized.target;

            switch (EditMode.editMode)
            {
            case EditBaseShape:
                InfluenceVolumeUI.DrawHandles_EditBase(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditInfluenceShape:
                InfluenceVolumeUI.DrawHandles_EditInfluence(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditInfluenceNormalShape:
                InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditCapturePosition:
            case EditMirrorPosition:
            {
                var proxyToWorldMatrix = probe.proxyToWorld;

                SerializedProperty target;
                switch (EditMode.editMode)
                {
                case EditCapturePosition: target = serialized.probeSettings.proxyCapturePositionProxySpace; break;

                case EditMirrorPosition: target = serialized.probeSettings.proxyMirrorPositionProxySpace; break;

                default: throw new ArgumentOutOfRangeException();
                }

                var position = proxyToWorldMatrix.MultiplyPoint(target.vector3Value);
                EditorGUI.BeginChangeCheck();
                position = Handles.PositionHandle(position, proxyToWorldMatrix.rotation);
                if (EditorGUI.EndChangeCheck())
                {
                    target.vector3Value = proxyToWorldMatrix.inverse.MultiplyPoint(position);
                }
                break;
            }

            case EditMirrorRotation:
            {
                var proxyToWorldMatrix = probe.proxyToWorld;

                var target   = serialized.probeSettings.proxyMirrorRotationProxySpace;
                var position = serialized.probeSettings.proxyMirrorPositionProxySpace.vector3Value;

                using (new Handles.DrawingScope(proxyToWorldMatrix))
                {
                    var rotation = target.quaternionValue;
                    EditorGUI.BeginChangeCheck();
                    rotation = Handles.RotationHandle(rotation, position);
                    if (EditorGUI.EndChangeCheck())
                    {
                        target.quaternionValue = rotation;
                    }
                }
                break;
            }
            }
        }