static void Drawer_SectionShapeSphere(SerializedInfluenceVolume serialized, Editor owner, bool drawOffset, bool drawNormal)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(serialized.sphereRadius, radiusContent);
            HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, owner, GUILayout.Width(28f), GUILayout.MinHeight(22f));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            var maxBlendDistance = serialized.sphereRadius.floatValue;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(serialized.sphereBlendDistance, blendDistanceContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.sphereBlendDistance.floatValue = Mathf.Clamp(serialized.sphereBlendDistance.floatValue, 0, maxBlendDistance);
            }
            HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, owner, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
            EditorGUILayout.EndHorizontal();

            if (drawNormal)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(serialized.sphereBlendNormalDistance, blendNormalDistanceContent);
                if (EditorGUI.EndChangeCheck())
                {
                    serialized.sphereBlendNormalDistance.floatValue = Mathf.Clamp(serialized.sphereBlendNormalDistance.floatValue, 0, maxBlendDistance);
                }
                HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, owner, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
                EditorGUILayout.EndHorizontal();
            }
        }
예제 #2
0
        internal SerializedProbeSettings(SerializedProperty root)
        {
            this.root = root;

            type                                 = root.Find((ProbeSettings p) => p.type);
            mode                                 = root.Find((ProbeSettings p) => p.mode);
            realtimeMode                         = root.Find((ProbeSettings p) => p.realtimeMode);
            lightingMultiplier                   = root.FindPropertyRelative("lighting.multiplier");
            lightingWeight                       = root.FindPropertyRelative("lighting.weight");
            lightingFadeDistance                 = root.FindPropertyRelative("lighting.fadeDistance");
            lightingLightLayer                   = root.FindPropertyRelative("lighting.lightLayer");
            lightingRangeCompressionFactor       = root.FindPropertyRelative("lighting.rangeCompressionFactor");
            proxyUseInfluenceVolumeAsProxyVolume = root.FindPropertyRelative("proxySettings.useInfluenceVolumeAsProxyVolume");
            proxyCapturePositionProxySpace       = root.FindPropertyRelative("proxySettings.capturePositionProxySpace");
            proxyCaptureRotationProxySpace       = root.FindPropertyRelative("proxySettings.captureRotationProxySpace");
            proxyMirrorPositionProxySpace        = root.FindPropertyRelative("proxySettings.mirrorPositionProxySpace");
            proxyMirrorRotationProxySpace        = root.FindPropertyRelative("proxySettings.mirrorRotationProxySpace");
            resolutionScalable                   = new SerializedScalableSettingValue(root.Find((ProbeSettings p) => p.resolutionScalable));
            roughReflections                     = root.FindPropertyRelative("roughReflections");
            distanceBasedRoughness               = root.FindPropertyRelative("distanceBasedRoughness");
            frustumFieldOfViewMode               = root.FindPropertyRelative("frustum.fieldOfViewMode");
            frustumFixedValue                    = root.FindPropertyRelative("frustum.fixedValue");
            frustumViewerScale                   = root.FindPropertyRelative("frustum.viewerScale");
            frustumAutomaticScale                = root.FindPropertyRelative("frustum.automaticScale");

            cameraSettings = new SerializedCameraSettings(root.Find((ProbeSettings p) => p.cameraSettings));
            influence      = new SerializedInfluenceVolume(root.Find((ProbeSettings p) => p.influence));
            proxy          = new SerializedProxyVolume(root.Find((ProbeSettings p) => p.proxy));
        }
        public static void SetInfluenceAdvancedControlSwitch(SerializedInfluenceVolume serialized, Editor owner, bool advancedControl)
        {
            if (advancedControl == serialized.editorAdvancedModeEnabled.boolValue)
            {
                return;
            }

            serialized.editorAdvancedModeEnabled.boolValue = advancedControl;
            if (advancedControl)
            {
                serialized.boxBlendDistancePositive.vector3Value       = serialized.editorAdvancedModeBlendDistancePositive.vector3Value;
                serialized.boxBlendDistanceNegative.vector3Value       = serialized.editorAdvancedModeBlendDistanceNegative.vector3Value;
                serialized.boxBlendNormalDistancePositive.vector3Value = serialized.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
                serialized.boxBlendNormalDistanceNegative.vector3Value = serialized.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
                serialized.boxSideFadePositive.vector3Value            = serialized.editorAdvancedModeFaceFadePositive.vector3Value;
                serialized.boxSideFadeNegative.vector3Value            = serialized.editorAdvancedModeFaceFadeNegative.vector3Value;
            }
            else
            {
                serialized.boxBlendDistanceNegative.vector3Value       = serialized.boxBlendDistancePositive.vector3Value = Vector3.one * serialized.editorSimplifiedModeBlendDistance.floatValue;
                serialized.boxBlendNormalDistanceNegative.vector3Value = serialized.boxBlendNormalDistancePositive.vector3Value = Vector3.one * serialized.editorSimplifiedModeBlendNormalDistance.floatValue;
                serialized.boxSideFadeNegative.vector3Value            = serialized.boxSideFadePositive.vector3Value = Vector3.one;
            }
            serialized.Apply();
        }
        public static void DrawHandles_EditBase(SerializedInfluenceVolume serialized, Editor owner, Transform transform)
        {
            switch ((InfluenceShape)serialized.shape.intValue)
            {
            case InfluenceShape.Box:
                DrawBoxHandle(serialized, owner, transform, s_BoxBaseHandle);
                break;

            case InfluenceShape.Sphere:
                using (new Handles.DrawingScope(Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one)))
                {
                    s_SphereBaseHandle.center = Vector3.zero;
                    s_SphereBaseHandle.radius = serialized.sphereRadius.floatValue;

                    EditorGUI.BeginChangeCheck();
                    s_SphereBaseHandle.DrawHull(true);
                    s_SphereBaseHandle.DrawHandle();
                    if (EditorGUI.EndChangeCheck())
                    {
                        Vector3 localSize = serialized.boxSize.vector3Value;
                        for (int i = 0; i < 3; ++i)
                        {
                            localSize[i] = Mathf.Max(Mathf.Epsilon, localSize[i]);
                        }
                        serialized.boxSize.vector3Value = localSize;
                        float radius = s_SphereBaseHandle.radius;
                        serialized.sphereRadius.floatValue              = radius;
                        serialized.sphereBlendDistance.floatValue       = Mathf.Clamp(serialized.sphereBlendDistance.floatValue, 0, radius);
                        serialized.sphereBlendNormalDistance.floatValue = Mathf.Clamp(serialized.sphereBlendNormalDistance.floatValue, 0, radius);
                    }
                    break;
                }
            }
        }
예제 #5
0
        public static void Draw <TProvider>(SerializedInfluenceVolume serialized, Editor owner)
            where TProvider : struct, IInfluenceUISettingsProvider
        {
            var provider = new TProvider();

            //small piece of init logic previously in the removed Drawer_InfluenceAdvancedSwitch
            bool advanced = serialized.editorAdvancedModeEnabled.boolValue;

            s_BoxBaseHandle.monoHandle            = false;
            s_BoxInfluenceHandle.monoHandle       = !advanced;
            s_BoxInfluenceNormalHandle.monoHandle = !advanced;

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(serialized.shape, shapeContent);
            switch ((InfluenceShape)serialized.shape.intValue)
            {
            case InfluenceShape.Box:
                Drawer_SectionShapeBox(serialized, owner, provider.drawOffset, provider.drawNormal, provider.drawFace);
                break;

            case InfluenceShape.Sphere:
                Drawer_SectionShapeSphere(serialized, owner, provider.drawOffset, provider.drawNormal);
                break;
            }
        }
        public static void DrawHandles_EditInfluenceNormal(SerializedInfluenceVolume serialized, Editor owner, Transform transform)
        {
            // Synchronize base handles
            s_BoxBaseHandle.center    = Vector3.zero;
            s_BoxBaseHandle.size      = serialized.boxSize.vector3Value;
            s_SphereBaseHandle.center = Vector3.zero;
            s_SphereBaseHandle.radius = serialized.sphereRadius.floatValue;

            switch ((InfluenceShape)serialized.shape.intValue)
            {
            case InfluenceShape.Box:
                EditorGUI.BeginChangeCheck();
                DrawBoxFadeHandle(serialized, owner, transform, s_BoxInfluenceNormalHandle, serialized.boxBlendNormalDistancePositive, serialized.boxBlendNormalDistanceNegative);
                if (EditorGUI.EndChangeCheck())
                {
                    //save advanced/simplified saved data
                    if (serialized.editorAdvancedModeEnabled.boolValue)
                    {
                        serialized.editorAdvancedModeBlendNormalDistancePositive.vector3Value = serialized.boxBlendNormalDistancePositive.vector3Value;
                        serialized.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = serialized.boxBlendNormalDistanceNegative.vector3Value;
                    }
                    else
                    {
                        serialized.editorSimplifiedModeBlendNormalDistance.floatValue = serialized.boxBlendNormalDistancePositive.vector3Value.x;
                    }
                    serialized.Apply();
                }
                break;

            case InfluenceShape.Sphere:
                DrawSphereFadeHandle(serialized, owner, transform, s_SphereInfluenceNormalHandle, serialized.sphereBlendNormalDistance);
                break;
            }
        }
        static void DrawBoxFadeHandle(SerializedInfluenceVolume serialized, Editor owner, Transform transform, HierarchicalBox box, SerializedProperty positive, SerializedProperty negative)
        {
            using (new Handles.DrawingScope(Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one)))
            {
                box.center     = -(positive.vector3Value - negative.vector3Value) * 0.5f;
                box.size       = serialized.boxSize.vector3Value - positive.vector3Value - negative.vector3Value;
                box.monoHandle = !serialized.editorAdvancedModeEnabled.boolValue;

                EditorGUI.BeginChangeCheck();
                box.DrawHandle();
                box.DrawHull(true);
                if (EditorGUI.EndChangeCheck())
                {
                    var influenceCenter   = Vector3.zero;
                    var halfInfluenceSize = serialized.boxSize.vector3Value * .5f;

                    var centerDiff            = box.center - influenceCenter;
                    var halfSizeDiff          = halfInfluenceSize - box.size * .5f;
                    var positiveNew           = halfSizeDiff - centerDiff;
                    var negativeNew           = halfSizeDiff + centerDiff;
                    var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, halfInfluenceSize));
                    var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, halfInfluenceSize));

                    positive.vector3Value = blendDistancePositive;
                    negative.vector3Value = blendDistanceNegative;
                }
            }
        }
예제 #8
0
        static void Drawer_AdvancedBlendDistance(SerializedInfluenceVolume serialized, bool isNormal, Vector3 maxBlendDistance, GUIContent content)
        {
            SerializedProperty blendDistancePositive = isNormal ? serialized.boxBlendNormalDistancePositive : serialized.boxBlendDistancePositive;
            SerializedProperty blendDistanceNegative = isNormal ? serialized.boxBlendNormalDistanceNegative : serialized.boxBlendDistanceNegative;
            SerializedProperty editorAdvancedModeBlendDistancePositive = isNormal ? serialized.editorAdvancedModeBlendNormalDistancePositive : serialized.editorAdvancedModeBlendDistancePositive;
            SerializedProperty editorAdvancedModeBlendDistanceNegative = isNormal ? serialized.editorAdvancedModeBlendNormalDistanceNegative : serialized.editorAdvancedModeBlendDistanceNegative;
            SerializedProperty editorSimplifiedModeBlendDistance       = isNormal ? serialized.editorSimplifiedModeBlendNormalDistance : serialized.editorSimplifiedModeBlendDistance;
            Vector3            bdp = blendDistancePositive.vector3Value;
            Vector3            bdn = blendDistanceNegative.vector3Value;

            EditorGUILayout.BeginVertical();

            if (serialized.editorAdvancedModeEnabled.boolValue)
            {
                EditorGUI.BeginChangeCheck();
                blendDistancePositive.vector3Value = editorAdvancedModeBlendDistancePositive.vector3Value;
                blendDistanceNegative.vector3Value = editorAdvancedModeBlendDistanceNegative.vector3Value;
                CoreEditorUtils.DrawVector6(content, blendDistancePositive, blendDistanceNegative, Vector3.zero, maxBlendDistance, k_HandlesColor);
                if (EditorGUI.EndChangeCheck())
                {
                    editorAdvancedModeBlendDistancePositive.vector3Value = blendDistancePositive.vector3Value;
                    editorAdvancedModeBlendDistanceNegative.vector3Value = blendDistanceNegative.vector3Value;
                }
            }
            else
            {
                float distance = editorSimplifiedModeBlendDistance.floatValue;
                EditorGUI.BeginChangeCheck();
                distance = EditorGUILayout.FloatField(content, distance);
                if (EditorGUI.EndChangeCheck())
                {
                    distance = Mathf.Clamp(distance, 0f, Mathf.Max(maxBlendDistance.x, maxBlendDistance.y, maxBlendDistance.z));
                    Vector3 decal = Vector3.one * distance;
                    bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
                    bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
                    bdp.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
                    bdn.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
                    bdn.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
                    bdn.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
                    blendDistancePositive.vector3Value           = bdp;
                    blendDistanceNegative.vector3Value           = bdn;
                    editorSimplifiedModeBlendDistance.floatValue = distance;
                }
            }

            GUILayout.EndVertical();
        }
        public static void Draw <TProvider>(SerializedInfluenceVolume serialized, Editor owner)
            where TProvider : struct, IInfluenceUISettingsProvider
        {
            var provider = new TProvider();

            EditorGUILayout.PropertyField(serialized.shape, shapeContent);
            switch ((InfluenceShape)serialized.shape.intValue)
            {
            case InfluenceShape.Box:
                Drawer_SectionShapeBox(serialized, owner, provider.drawOffset, provider.drawNormal, provider.drawFace);
                break;

            case InfluenceShape.Sphere:
                Drawer_SectionShapeSphere(serialized, owner, provider.drawOffset, provider.drawNormal);
                break;
            }
        }
        static void Drawer_InfluenceAdvancedSwitch(SerializedInfluenceVolume serialized, Editor owner)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (serialized.shape.intValue == (int)InfluenceShape.Sphere)
                {
                    GUI.enabled = false;
                }

                bool advanced = serialized.editorAdvancedModeEnabled.boolValue;
                advanced = !GUILayout.Toggle(!advanced, normalModeContent, EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
                advanced = GUILayout.Toggle(advanced, advancedModeContent, EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
                s_BoxBaseHandle.monoHandle            = false;
                s_BoxInfluenceHandle.monoHandle       = !advanced;
                s_BoxInfluenceNormalHandle.monoHandle = !advanced;
                if (serialized.editorAdvancedModeEnabled.boolValue ^ advanced)
                {
                    serialized.editorAdvancedModeEnabled.boolValue = advanced;
                    if (advanced)
                    {
                        serialized.boxBlendDistancePositive.vector3Value       = serialized.editorAdvancedModeBlendDistancePositive.vector3Value;
                        serialized.boxBlendDistanceNegative.vector3Value       = serialized.editorAdvancedModeBlendDistanceNegative.vector3Value;
                        serialized.boxBlendNormalDistancePositive.vector3Value = serialized.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
                        serialized.boxBlendNormalDistanceNegative.vector3Value = serialized.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
                        serialized.boxSideFadePositive.vector3Value            = serialized.editorAdvancedModeFaceFadePositive.vector3Value;
                        serialized.boxSideFadeNegative.vector3Value            = serialized.editorAdvancedModeFaceFadeNegative.vector3Value;
                    }
                    else
                    {
                        serialized.boxBlendDistanceNegative.vector3Value       = serialized.boxBlendDistancePositive.vector3Value = Vector3.one * serialized.editorSimplifiedModeBlendDistance.floatValue;
                        serialized.boxBlendNormalDistanceNegative.vector3Value = serialized.boxBlendNormalDistancePositive.vector3Value = Vector3.one * serialized.editorSimplifiedModeBlendNormalDistance.floatValue;
                        serialized.boxSideFadeNegative.vector3Value            = serialized.boxSideFadePositive.vector3Value = Vector3.one;
                    }
                    serialized.Apply();
                }

                if (serialized.shape.intValue == (int)InfluenceShape.Sphere)
                {
                    GUI.enabled = true;
                }
            }
        }
        static void DrawSphereFadeHandle(SerializedInfluenceVolume serialized, Editor owner, Transform transform, HierarchicalSphere sphere, SerializedProperty radius)
        {
            //init parent sphere for clamping
            s_SphereBaseHandle.center = Vector3.zero;
            s_SphereBaseHandle.radius = serialized.sphereRadius.floatValue;

            using (new Handles.DrawingScope(Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one)))
            {
                sphere.center = Vector3.zero;
                sphere.radius = serialized.sphereRadius.floatValue - radius.floatValue;

                EditorGUI.BeginChangeCheck();
                sphere.DrawHull(true);
                sphere.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    radius.floatValue = Mathf.Clamp(serialized.sphereRadius.floatValue - sphere.radius, 0, serialized.sphereRadius.floatValue);
                }
            }
        }
        internal SerializedProbeSettings(SerializedProperty root)
        {
            this.root = root;

            type               = root.Find((ProbeSettings p) => p.type);
            mode               = root.Find((ProbeSettings p) => p.mode);
            realtimeMode       = root.Find((ProbeSettings p) => p.realtimeMode);
            lightingMultiplier = root.FindPropertyRelative("lighting.multiplier");
            lightingWeight     = root.FindPropertyRelative("lighting.weight");
            lightingLightLayer = root.FindPropertyRelative("lighting.lightLayer");
            proxyUseInfluenceVolumeAsProxyVolume = root.FindPropertyRelative("proxySettings.useInfluenceVolumeAsProxyVolume");
            proxyCapturePositionProxySpace       = root.FindPropertyRelative("proxySettings.capturePositionProxySpace");
            proxyCaptureRotationProxySpace       = root.FindPropertyRelative("proxySettings.captureRotationProxySpace");
            proxyMirrorPositionProxySpace        = root.FindPropertyRelative("proxySettings.mirrorPositionProxySpace");
            proxyMirrorRotationProxySpace        = root.FindPropertyRelative("proxySettings.mirrorRotationProxySpace");
            frustumFieldOfViewMode = root.FindPropertyRelative("frustum.fieldOfViewMode");
            frustumFixedValue      = root.FindPropertyRelative("frustum.fixedValue");
            frustumViewerScale     = root.FindPropertyRelative("frustum.viewerScale");
            frustumAutomaticScale  = root.FindPropertyRelative("frustum.automaticScale");

            cameraSettings = new SerializedCameraSettings(root.Find((ProbeSettings p) => p.camera));
            influence      = new SerializedInfluenceVolume(root.Find((ProbeSettings p) => p.influence));
            proxy          = new SerializedProxyVolume(root.Find((ProbeSettings p) => p.proxy));
        }
        static void Drawer_SectionShapeBox(SerializedInfluenceVolume serialized, Editor owner, bool drawOffset, bool drawNormal, bool drawFace)
        {
            bool advanced = serialized.editorAdvancedModeEnabled.boolValue;

            //small piece of init logic previously in the removed Drawer_InfluenceAdvancedSwitch
            s_BoxBaseHandle.monoHandle            = false;
            s_BoxInfluenceHandle.monoHandle       = !advanced;
            s_BoxInfluenceNormalHandle.monoHandle = !advanced;

            var maxFadeDistance = serialized.boxSize.vector3Value * 0.5f;
            var minFadeDistance = Vector3.zero;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(serialized.boxSize, boxSizeContent);
            if (EditorGUI.EndChangeCheck())
            {
                Vector3 localSize = serialized.boxSize.vector3Value;
                for (int i = 0; i < 3; ++i)
                {
                    localSize[i] = Mathf.Max(Mathf.Epsilon, localSize[i]);
                }
                serialized.boxSize.vector3Value = localSize;

                Vector3 blendPositive       = serialized.boxBlendDistancePositive.vector3Value;
                Vector3 blendNegative       = serialized.boxBlendDistanceNegative.vector3Value;
                Vector3 blendNormalPositive = serialized.boxBlendNormalDistancePositive.vector3Value;
                Vector3 blendNormalNegative = serialized.boxBlendNormalDistanceNegative.vector3Value;
                Vector3 size = serialized.boxSize.vector3Value;
                for (int i = 0; i < 3; ++i)
                {
                    size[i] = Mathf.Max(0f, size[i]);
                }
                serialized.boxSize.vector3Value = size;
                Vector3 halfSize = size * .5f;
                for (int i = 0; i < 3; ++i)
                {
                    blendPositive[i]       = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]);
                    blendNegative[i]       = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]);
                    blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]);
                    blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]);
                }
                serialized.boxBlendDistancePositive.vector3Value       = blendPositive;
                serialized.boxBlendDistanceNegative.vector3Value       = blendNegative;
                serialized.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive;
                serialized.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative;
                if (serialized.editorAdvancedModeEnabled.boolValue)
                {
                    serialized.editorAdvancedModeBlendDistancePositive.vector3Value       = serialized.boxBlendDistancePositive.vector3Value;
                    serialized.editorAdvancedModeBlendDistanceNegative.vector3Value       = serialized.boxBlendDistanceNegative.vector3Value;
                    serialized.editorAdvancedModeBlendNormalDistancePositive.vector3Value = serialized.boxBlendNormalDistancePositive.vector3Value;
                    serialized.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = serialized.boxBlendNormalDistanceNegative.vector3Value;
                }
                else
                {
                    serialized.editorSimplifiedModeBlendDistance.floatValue       = Mathf.Max(blendPositive.x, blendPositive.y, blendPositive.z, blendNegative.x, blendNegative.y, blendNegative.z);
                    serialized.boxBlendDistancePositive.vector3Value              = serialized.boxBlendDistanceNegative.vector3Value = Vector3.one * serialized.editorSimplifiedModeBlendDistance.floatValue;
                    serialized.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Max(blendNormalPositive.x, blendNormalPositive.y, blendNormalPositive.z, blendNormalNegative.x, blendNormalNegative.y, blendNormalNegative.z);
                    serialized.boxBlendNormalDistancePositive.vector3Value        = serialized.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * serialized.editorSimplifiedModeBlendNormalDistance.floatValue;
                }
            }
            HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, owner, GUILayout.Width(28f), GUILayout.MinHeight(22f));
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);

            EditorGUILayout.PropertyField(serialized.editorAdvancedModeEnabled, manipulatonTypeContent);

            EditorGUILayout.BeginHorizontal();
            Drawer_AdvancedBlendDistance(serialized, false, maxFadeDistance, blendDistanceContent);
            HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, owner, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 2 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
            EditorGUILayout.EndHorizontal();

            if (drawNormal)
            {
                EditorGUILayout.BeginHorizontal();
                Drawer_AdvancedBlendDistance(serialized, true, maxFadeDistance, blendNormalDistanceContent);
                HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, owner, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 2 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
                EditorGUILayout.EndHorizontal();
            }

            if (advanced && drawFace)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                CoreEditorUtils.DrawVector6(faceFadeContent, serialized.editorAdvancedModeFaceFadePositive, serialized.editorAdvancedModeFaceFadeNegative, Vector3.zero, Vector3.one, k_HandlesColor);
                if (EditorGUI.EndChangeCheck())
                {
                    serialized.boxSideFadePositive.vector3Value = serialized.editorAdvancedModeFaceFadePositive.vector3Value;
                    serialized.boxSideFadeNegative.vector3Value = serialized.editorAdvancedModeFaceFadeNegative.vector3Value;
                }
                GUILayout.Space(30f); //add right margin for alignment
                EditorGUILayout.EndHorizontal();
            }
        }
        static void Drawer_AdvancedBlendDistance(SerializedInfluenceVolume serialized, bool isNormal, Vector3 maxBlendDistance, GUIContent content)
        {
            SerializedProperty blendDistancePositive = isNormal ? serialized.boxBlendNormalDistancePositive : serialized.boxBlendDistancePositive;
            SerializedProperty blendDistanceNegative = isNormal ? serialized.boxBlendNormalDistanceNegative : serialized.boxBlendDistanceNegative;
            SerializedProperty editorAdvancedModeBlendDistancePositive = isNormal ? serialized.editorAdvancedModeBlendNormalDistancePositive : serialized.editorAdvancedModeBlendDistancePositive;
            SerializedProperty editorAdvancedModeBlendDistanceNegative = isNormal ? serialized.editorAdvancedModeBlendNormalDistanceNegative : serialized.editorAdvancedModeBlendDistanceNegative;
            SerializedProperty editorSimplifiedModeBlendDistance       = isNormal ? serialized.editorSimplifiedModeBlendNormalDistance : serialized.editorSimplifiedModeBlendDistance;
            Vector3            bdp = blendDistancePositive.vector3Value;
            Vector3            bdn = blendDistanceNegative.vector3Value;

            //resync to be sure prefab revert will keep syncs
            if (serialized.editorAdvancedModeEnabled.boolValue)
            {
                if (!(Mathf.Approximately(Vector3.SqrMagnitude(blendDistancePositive.vector3Value - editorAdvancedModeBlendDistancePositive.vector3Value), 0f) &&
                      Mathf.Approximately(Vector3.SqrMagnitude(blendDistanceNegative.vector3Value - editorAdvancedModeBlendDistanceNegative.vector3Value), 0f)))
                {
                    blendDistancePositive.vector3Value = editorAdvancedModeBlendDistancePositive.vector3Value;
                    blendDistanceNegative.vector3Value = editorAdvancedModeBlendDistanceNegative.vector3Value;
                    serialized.Apply();
                    SceneView.RepaintAll(); //update gizmo
                }
            }
            else
            {
                float scalar = editorSimplifiedModeBlendDistance.floatValue;
                if (!(Mathf.Approximately(blendDistancePositive.vector3Value.x, scalar) &&
                      Mathf.Approximately(blendDistancePositive.vector3Value.y, scalar) &&
                      Mathf.Approximately(blendDistancePositive.vector3Value.z, scalar) &&
                      Mathf.Approximately(blendDistanceNegative.vector3Value.x, scalar) &&
                      Mathf.Approximately(blendDistanceNegative.vector3Value.y, scalar) &&
                      Mathf.Approximately(blendDistanceNegative.vector3Value.z, scalar)))
                {
                    blendDistancePositive.vector3Value = blendDistanceNegative.vector3Value = new Vector3(scalar, scalar, scalar);
                    serialized.Apply();
                    SceneView.RepaintAll(); //update gizmo
                }
            }

            if (serialized.editorAdvancedModeEnabled.boolValue)
            {
                EditorGUI.BeginChangeCheck();
                CoreEditorUtils.DrawVector6(content, editorAdvancedModeBlendDistancePositive, editorAdvancedModeBlendDistanceNegative, Vector3.zero, maxBlendDistance, k_HandlesColor);
                if (EditorGUI.EndChangeCheck())
                {
                    blendDistancePositive.vector3Value = editorAdvancedModeBlendDistancePositive.vector3Value;
                    blendDistanceNegative.vector3Value = editorAdvancedModeBlendDistanceNegative.vector3Value;
                }
            }
            else
            {
                Rect lineRect = EditorGUILayout.GetControlRect();
                EditorGUI.BeginProperty(lineRect, content, editorSimplifiedModeBlendDistance);
                float distance = editorSimplifiedModeBlendDistance.floatValue;
                EditorGUI.BeginChangeCheck();
                distance = EditorGUI.FloatField(lineRect, content, distance);
                if (EditorGUI.EndChangeCheck())
                {
                    distance = Mathf.Clamp(distance, 0f, Mathf.Max(maxBlendDistance.x, maxBlendDistance.y, maxBlendDistance.z));
                    Vector3 decal = Vector3.one * distance;
                    bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
                    bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
                    bdp.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
                    bdn.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
                    bdn.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
                    bdn.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
                    blendDistancePositive.vector3Value           = bdp;
                    blendDistanceNegative.vector3Value           = bdn;
                    editorSimplifiedModeBlendDistance.floatValue = distance;
                }
                EditorGUI.EndProperty();
            }
        }
        static void DrawBoxHandle(SerializedInfluenceVolume serialized, Editor owner, Transform transform, HierarchicalBox box)
        {
            using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, transform.rotation, Vector3.one)))
            {
                box.center = Quaternion.Inverse(transform.rotation) * transform.position;
                box.size   = serialized.boxSize.vector3Value;

                EditorGUI.BeginChangeCheck();
                box.DrawHull(true);
                box.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    // Clamp blend distances
                    var blendPositive       = serialized.boxBlendDistancePositive.vector3Value;
                    var blendNegative       = serialized.boxBlendDistanceNegative.vector3Value;
                    var blendNormalPositive = serialized.boxBlendNormalDistancePositive.vector3Value;
                    var blendNormalNegative = serialized.boxBlendNormalDistanceNegative.vector3Value;
                    var size = box.size;
                    serialized.boxSize.vector3Value = size;
                    var halfSize = size * .5f;
                    for (int i = 0; i < 3; ++i)
                    {
                        blendPositive[i]       = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]);
                        blendNegative[i]       = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]);
                        blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]);
                        blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]);
                    }
                    serialized.boxBlendDistancePositive.vector3Value       = blendPositive;
                    serialized.boxBlendDistanceNegative.vector3Value       = blendNegative;
                    serialized.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive;
                    serialized.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative;

                    if (serialized.editorAdvancedModeEnabled.boolValue)
                    {
                        serialized.editorAdvancedModeBlendDistancePositive.vector3Value       = serialized.boxBlendDistancePositive.vector3Value;
                        serialized.editorAdvancedModeBlendDistanceNegative.vector3Value       = serialized.boxBlendDistanceNegative.vector3Value;
                        serialized.editorAdvancedModeBlendNormalDistancePositive.vector3Value = serialized.boxBlendNormalDistancePositive.vector3Value;
                        serialized.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = serialized.boxBlendNormalDistanceNegative.vector3Value;
                    }
                    else
                    {
                        serialized.editorSimplifiedModeBlendDistance.floatValue = Mathf.Min(
                            serialized.boxBlendDistancePositive.vector3Value.x,
                            serialized.boxBlendDistancePositive.vector3Value.y,
                            serialized.boxBlendDistancePositive.vector3Value.z,
                            serialized.boxBlendDistanceNegative.vector3Value.x,
                            serialized.boxBlendDistanceNegative.vector3Value.y,
                            serialized.boxBlendDistanceNegative.vector3Value.z);
                        serialized.boxBlendDistancePositive.vector3Value = serialized.boxBlendDistanceNegative.vector3Value = Vector3.one * serialized.editorSimplifiedModeBlendDistance.floatValue;
                        serialized.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Min(
                            serialized.boxBlendNormalDistancePositive.vector3Value.x,
                            serialized.boxBlendNormalDistancePositive.vector3Value.y,
                            serialized.boxBlendNormalDistancePositive.vector3Value.z,
                            serialized.boxBlendNormalDistanceNegative.vector3Value.x,
                            serialized.boxBlendNormalDistanceNegative.vector3Value.y,
                            serialized.boxBlendNormalDistanceNegative.vector3Value.z);
                        serialized.boxBlendNormalDistancePositive.vector3Value = serialized.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * serialized.editorSimplifiedModeBlendNormalDistance.floatValue;
                    }
                }
            }
        }