示例#1
0
    private void OnGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();

        bool isButtonClicked = GUILayout.Button("Migrate lights", EditorStyles.toolbarButton, GUILayout.Width(120.0f),
                                                GUILayout.Height(70.0f));

        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        if (isButtonClicked)
        {
            var lights       = Resources.FindObjectsOfTypeAll <Light>();
            var lightsLength = lights.Length;

            for (int i = 0; i < lightsLength; i++)
            {
                var light = lights[i];

                EditorUtility.DisplayProgressBar(
                    "Converting lights...",
                    string.Format("{0} / {1} converted.", i, lightsLength),
                    i / (lightsLength - 1.0f));


                // Skip Unity baked Area Lights.
                if (light.type == LightType.Area)
                {
                    continue;
                }

                //Prefab, skip
                if (EditorUtility.IsPersistent(light))
                {
                    continue;
                }

                AlloyAreaLight area = light.GetComponent <AlloyAreaLight>();

                // Skip if it is already and area light.
                if (area == null)
                {
                    Undo.RecordObject(light.gameObject, "Convert to area light");
                    area = Undo.AddComponent <AlloyAreaLight>(light.gameObject);
                }

                Undo.RecordObject(light, "Set light cookie");
                area.UpdateBinding();
            }

            EditorUtility.ClearProgressBar();
        }
    }
        public void Deserializ(Light light, int index, OCILight ocLight = null)
        {
            light.transform.localPosition    = ToVector3(transform_localPosition[index]);
            light.transform.eulerAngles      = ToVector3(transform_eulerAngles[index]);
            light.transform.localEulerAngles = ToVector3(transform_localEulerAngles[index]);
            light.transform.right            = ToVector3(transform_right[index]);
            light.transform.up            = ToVector3(transform_up[index]);
            light.transform.forward       = ToVector3(transform_forward[index]);
            light.transform.rotation      = ToQuaternion(transform_rotation[index]);
            light.transform.position      = ToVector3(transform_position[index]);
            light.transform.localRotation = ToQuaternion(transform_localRotation[index]);
            light.transform.localScale    = ToVector3(transform_localScale[index]);
            light.enabled                = (int.Parse(enabled[index]) == 1);
            light.name                   = name[index];
            light.range                  = float.Parse(range[index]);
            light.spotAngle              = float.Parse(spotAngle[index]);
            light.cookieSize             = float.Parse(cookieSize[index]);
            light.renderMode             = (LightRenderMode)(int.Parse(renderMode[index]));
            light.bakedIndex             = int.Parse(bakedIndex[index]);
            light.cullingMask            = int.Parse(cullingMask[index]);
            light.shadowNearPlane        = float.Parse(shadowNearPlane[index]);
            light.shadowBias             = float.Parse(shadowBias[index]);
            light.shadowNormalBias       = float.Parse(shadowNormalBias[index]);
            light.color                  = ToColor(color[index]);
            light.intensity              = float.Parse(intensity[index]);
            light.bounceIntensity        = float.Parse(bounceIntensity[index]);
            light.type                   = (LightType)(int.Parse(type[index]));
            light.shadowStrength         = float.Parse(shadowStrength[index]);
            light.shadowResolution       = (LightShadowResolution)(int.Parse(shadowResolution[index]));
            light.shadowCustomResolution = int.Parse(shadowCustomResolution[index]);
            light.shadows                = (LightShadows)(int.Parse(shadows[index]));

            AlloyAreaLight alloyAreaLight = light.GetComponent <AlloyAreaLight>();

            if (alloyAreaLight != null)
            {
                alloyAreaLight.transform.localPosition    = ToVector3(alloy_transform_localPosition[index]);
                alloyAreaLight.transform.eulerAngles      = ToVector3(alloy_transform_eulerAngles[index]);
                alloyAreaLight.transform.localEulerAngles = ToVector3(alloy_transform_localEulerAngles[index]);
                alloyAreaLight.transform.right            = ToVector3(alloy_transform_right[index]);
                alloyAreaLight.transform.up            = ToVector3(alloy_transform_up[index]);
                alloyAreaLight.transform.forward       = ToVector3(alloy_transform_forward[index]);
                alloyAreaLight.transform.rotation      = ToQuaternion(alloy_transform_rotation[index]);
                alloyAreaLight.transform.position      = ToVector3(alloy_transform_position[index]);
                alloyAreaLight.transform.localRotation = ToQuaternion(alloy_transform_localRotation[index]);
                alloyAreaLight.transform.localScale    = ToVector3(alloy_transform_localScale[index]);
                alloyAreaLight.enabled              = (int.Parse(alloy_enabled[index]) == 1);
                alloyAreaLight.Radius               = float.Parse(alloy_Radius[index]);
                alloyAreaLight.Length               = float.Parse(alloy_Length[index]);
                alloyAreaLight.Intensity            = float.Parse(alloy_Intensity[index]);
                alloyAreaLight.Color                = ToColor(alloy_Color[index]);
                alloyAreaLight.HasSpecularHighlight = (int.Parse(alloy_HasSpecularHighlight[index]) == 1);
                alloyAreaLight.IsAnimatedByClip     = (int.Parse(alloy_IsAnimatedByClip[index]) == 1);
            }

            if (ocLight != null)
            {
                ocLight.lightTarget          = (Info.LightLoadInfo.Target)(int.Parse(oc_lightTarget[index]));
                ocLight.lightInfo.color      = ToColor(ocinfo_color[index]);
                ocLight.lightInfo.intensity  = float.Parse(ocinfo_intensity[index]);
                ocLight.lightInfo.range      = float.Parse(ocinfo_range[index]);
                ocLight.lightInfo.spotAngle  = float.Parse(ocinfo_spotAngle[index]);
                ocLight.lightInfo.shadow     = (int.Parse(ocinfo_shadow[index]) == 1);
                ocLight.lightInfo.enable     = (int.Parse(ocinfo_enable[index]) == 1);
                ocLight.lightInfo.drawTarget = (int.Parse(ocinfo_drawTarget[index]) == 1);
            }
        }
        public void Serializ(Light light, OCILight ocLight = null)
        {
            hierarchyPath.Add(GetHierarchyPath(light));
            transform_localPosition.Add(ToString(light.transform.localPosition));
            transform_eulerAngles.Add(ToString(light.transform.eulerAngles));
            transform_localEulerAngles.Add(ToString(light.transform.localEulerAngles));
            transform_right.Add(ToString(light.transform.right));
            transform_up.Add(ToString(light.transform.up));
            transform_forward.Add(ToString(light.transform.forward));
            transform_rotation.Add(ToString(light.transform.rotation));
            transform_position.Add(ToString(light.transform.position));
            transform_localRotation.Add(ToString(light.transform.localRotation));
            transform_localScale.Add(ToString(light.transform.localScale));
            enabled.Add(Convert.ToInt32(light.enabled).ToString());
            hashCode.Add(light.GetHashCode().ToString());
            instanceId.Add(light.GetInstanceID().ToString());
            name.Add(light.name);
            range.Add(light.range.ToString());
            spotAngle.Add(light.spotAngle.ToString());
            cookieSize.Add(light.cookieSize.ToString());
            renderMode.Add(((int)(light.renderMode)).ToString());
            bakedIndex.Add(light.bakedIndex.ToString());
            cullingMask.Add(light.cullingMask.ToString());
            shadowNearPlane.Add(light.shadowNearPlane.ToString());
            shadowBias.Add(light.shadowBias.ToString());
            shadowNormalBias.Add(light.shadowNormalBias.ToString());
            color.Add(ToString(light.color));
            intensity.Add(light.intensity.ToString());
            bounceIntensity.Add(light.bounceIntensity.ToString());
            type.Add(((int)(light.type)).ToString());
            shadowStrength.Add(light.shadowStrength.ToString());
            shadowResolution.Add(((int)(light.shadowResolution)).ToString());
            shadowCustomResolution.Add(light.shadowCustomResolution.ToString());
            shadows.Add(((int)(light.shadows)).ToString());

            AlloyAreaLight alloyAreaLight = light.GetComponent <AlloyAreaLight>();

            if (alloyAreaLight != null)
            {
                alloy_transform_localPosition.Add(ToString(alloyAreaLight.transform.localPosition));
                alloy_transform_eulerAngles.Add(ToString(alloyAreaLight.transform.eulerAngles));
                alloy_transform_localEulerAngles.Add(ToString(alloyAreaLight.transform.localEulerAngles));
                alloy_transform_right.Add(ToString(alloyAreaLight.transform.right));
                alloy_transform_up.Add(ToString(alloyAreaLight.transform.up));
                alloy_transform_forward.Add(ToString(alloyAreaLight.transform.forward));
                alloy_transform_rotation.Add(ToString(alloyAreaLight.transform.rotation));
                alloy_transform_position.Add(ToString(alloyAreaLight.transform.position));
                alloy_transform_localRotation.Add(ToString(alloyAreaLight.transform.localRotation));
                alloy_transform_localScale.Add(ToString(alloyAreaLight.transform.localScale));
                alloy_enabled.Add(Convert.ToInt32(alloyAreaLight.enabled).ToString());
                alloy_Radius.Add(alloyAreaLight.Radius.ToString());
                alloy_Length.Add(alloyAreaLight.Length.ToString());
                alloy_Intensity.Add(alloyAreaLight.Intensity.ToString());
                alloy_Color.Add(ToString(alloyAreaLight.Color));
                alloy_HasSpecularHighlight.Add(Convert.ToInt32(alloyAreaLight.HasSpecularHighlight).ToString());
                alloy_IsAnimatedByClip.Add(Convert.ToInt32(alloyAreaLight.IsAnimatedByClip).ToString());
            }
            else
            {
                alloy_transform_localPosition.Add("");
                alloy_transform_eulerAngles.Add("");
                alloy_transform_localEulerAngles.Add("");
                alloy_transform_right.Add("");
                alloy_transform_up.Add("");
                alloy_transform_forward.Add("");
                alloy_transform_rotation.Add("");
                alloy_transform_position.Add("");
                alloy_transform_localRotation.Add("");
                alloy_transform_localScale.Add("");
                alloy_enabled.Add("");
                alloy_Radius.Add("");
                alloy_Length.Add("");
                alloy_Intensity.Add("");
                alloy_Color.Add("");
                alloy_HasSpecularHighlight.Add("");
                alloy_IsAnimatedByClip.Add("");
            }
            if (ocLight != null)
            {
                hasStudio.Add(Convert.ToInt32(true).ToString());

                oc_lightTarget.Add(((int)(ocLight.lightTarget)).ToString());
                ocinfo_color.Add(ToString(ocLight.lightInfo.color));
                ocinfo_intensity.Add(ocLight.lightInfo.intensity.ToString());
                ocinfo_range.Add(ocLight.lightInfo.range.ToString());
                ocinfo_spotAngle.Add(ocLight.lightInfo.spotAngle.ToString());
                ocinfo_shadow.Add(Convert.ToInt32(ocLight.lightInfo.shadow).ToString());
                ocinfo_enable.Add(Convert.ToInt32(ocLight.lightInfo.enable).ToString());
                ocinfo_drawTarget.Add(Convert.ToInt32(ocLight.lightInfo.drawTarget).ToString());
            }
            else
            {
                hasStudio.Add(Convert.ToInt32(false).ToString());

                oc_lightTarget.Add("");
                ocinfo_color.Add("");
                ocinfo_intensity.Add("");
                ocinfo_range.Add("");
                ocinfo_spotAngle.Add("");
                ocinfo_shadow.Add("");
                ocinfo_enable.Add("");
                ocinfo_drawTarget.Add("");
            }
        }
示例#4
0
        internal static void Draw(GlobalSettings renderingSettings, LightManager lightManager, bool showAdvanced)
        {
            GUILayout.BeginVertical(GUIStyles.Skin.box);
            {
                if (showAdvanced)
                {
                    Toggle("Use Alloy Light", lightManager.UseAlloyLight, false, useAlloy => lightManager.UseAlloyLight = useAlloy);
                    Toggle("Lights Use Linear Intensity", renderingSettings.LightsUseLinearIntensity, false, useLinear => renderingSettings.LightsUseLinearIntensity         = useLinear);
                    Toggle("Lights Use Color Temperature", renderingSettings.LightsUseColorTemperature, false, useTemperature => renderingSettings.LightsUseColorTemperature = useTemperature);
                }
                GUILayout.BeginHorizontal();
                {
                    GUILayout.BeginVertical(GUIStyles.Skin.box, GUILayout.Width(200), GUILayout.MaxWidth(250));
                    {
                        LightGroup(lightManager, "Directional Lights", LightSettings.LightType.Directional);
                        if (0 < lightManager.DirectionalLights.Count)
                        {
                            GUILayout.BeginVertical(GUIStyles.Skin.box);
                            dirLightScrollView = GUILayout.BeginScrollView(dirLightScrollView);
                            lightManager.DirectionalLights.ForEach(l => LightOverviewModule(lightManager, l));
                            GUILayout.FlexibleSpace();
                            GUILayout.EndScrollView();
                            GUILayout.EndVertical();
                        }
                        LightGroup(lightManager, "Point Lights", LightSettings.LightType.Point);
                        if (0 < lightManager.PointLights.Count)
                        {
                            GUILayout.BeginVertical(GUIStyles.Skin.box);
                            pointLightScrollView = GUILayout.BeginScrollView(pointLightScrollView);
                            lightManager.PointLights.ForEach(l => LightOverviewModule(lightManager, l));
                            GUILayout.FlexibleSpace();
                            GUILayout.EndScrollView();
                            GUILayout.EndVertical();
                        }
                        LightGroup(lightManager, "Spot Lights", LightSettings.LightType.Spot);
                        if (0 < lightManager.SpotLights.Count)
                        {
                            GUILayout.BeginVertical(GUIStyles.Skin.box);
                            spotLightScrollView = GUILayout.BeginScrollView(spotLightScrollView);
                            lightManager.SpotLights.ForEach(l => LightOverviewModule(lightManager, l));
                            GUILayout.FlexibleSpace();
                            GUILayout.EndScrollView();
                            GUILayout.EndVertical();
                        }
                    }
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical(GUIStyles.Skin.box);
                    {
                        if (null != lightManager.SelectedLight)
                        {
                            if (lightManager.SelectedLight.enabled)
                            {
                                AlloyAreaLight alloyLight = null;
                                if (lightManager.UseAlloyLight)
                                {
                                    alloyLight = lightManager.SelectedLight.light.GetComponent <AlloyAreaLight>();
                                }
                                Label(lightManager.SelectedLight.light.name, "", true);
                                GUILayout.BeginVertical(GUIStyles.Skin.box);
                                inspectorScrollView = GUILayout.BeginScrollView(inspectorScrollView);
                                {
                                    Label("Colour", "", true);
                                    SliderColor("Colour", lightManager.SelectedLight.color, c => lightManager.SelectedLight.color = c);
                                    if (renderingSettings.LightsUseColorTemperature)
                                    {
                                        Slider("Temperature (K)", lightManager.SelectedLight.light.colorTemperature, 0f, 30000f, "N0", t => lightManager.SelectedLight.light.colorTemperature = t);
                                    }
                                    GUILayout.Space(10);
                                    Label("Shadows", "", true);
                                    Selection("Shadow Type", lightManager.SelectedLight.shadows, type => lightManager.SelectedLight.shadows = type);
                                    Slider("Strength", lightManager.SelectedLight.light.shadowStrength, 0f, 1f, "N2", strength => lightManager.SelectedLight.light.shadowStrength = strength);
                                    if (LightType.Directional == lightManager.SelectedLight.type && renderingSettings.UsePCSS)
                                    {
                                        Slider("Resolution", lightManager.SelectedLight.ShadowCustomResolution, 0, PCSSLight.MaxShadowCustomResolution, resolution => lightManager.SelectedLight.ShadowCustomResolution = resolution);
                                    }
                                    else
                                    {
                                        Selection("Resolution", lightManager.SelectedLight.light.shadowResolution, resolution => lightManager.SelectedLight.light.shadowResolution = resolution, 2);
                                    }
                                    Slider("Bias", lightManager.SelectedLight.light.shadowBias, 0f, 2f, "N3", bias => lightManager.SelectedLight.light.shadowBias = bias);
                                    Slider("Normal Bias", lightManager.SelectedLight.light.shadowNormalBias, 0f, 3f, "N2", nbias => lightManager.SelectedLight.light.shadowNormalBias = nbias);
                                    Slider("Near Plane", lightManager.SelectedLight.light.shadowNearPlane, 0f, 10f, "N2", np => lightManager.SelectedLight.light.shadowNearPlane      = np);
                                    GUILayout.Space(10);
                                    Slider("Intensity", lightManager.SelectedLight.intensity, LightSettings.IntensityMin, LightSettings.IntensityMax, "N2", i => lightManager.SelectedLight.intensity = i);
                                    Slider("Indirect Multiplier", lightManager.SelectedLight.light.bounceIntensity, LightSettings.IntensityMin, LightSettings.IntensityMax, "N0", bi => lightManager.SelectedLight.light.bounceIntensity = bi);
                                    GUILayout.Space(10);
                                    if (lightManager.SelectedLight.type == LightType.Directional)
                                    {
                                        if (null != Graphics.Instance.CameraSettings.MainCamera && null == segi)
                                        {
                                            segi = Graphics.Instance.CameraSettings.MainCamera.GetComponent <SEGI>();
                                        }

                                        if (null != segi && segi.enabled)
                                        {
                                            bool isSEGISun = ReferenceEquals(lightManager.SelectedLight.light, segi.sun);
                                            if (null != segi.sun && !isSEGISun)
                                            {
                                                GUI.enabled = false;
                                            }
                                            Toggle("SEGI Sun source", isSEGISun, false, sun =>
                                            {
                                                if (sun)
                                                {
                                                    segi.sun = lightManager.SelectedLight.light;
                                                }
                                                else
                                                {
                                                    segi.sun = null;
                                                }
                                            });
                                            GUI.enabled = true;
                                        }

                                        Vector3 rot = lightManager.SelectedLight.rotation;
                                        Slider("Vertical Rotation", rot.x, LightSettings.RotationXMin, LightSettings.RotationXMax, "N1", x => { rot.x = x; });
                                        Slider("Horizontal Rotation", rot.y, LightSettings.RotationYMin, LightSettings.RotationYMax, "N1", y => { rot.y = y; });

                                        if (rot != lightManager.SelectedLight.rotation)
                                        {
                                            lightManager.SelectedLight.rotation = rot;
                                        }
                                    }
                                    else
                                    {
                                        Slider("Light Range", lightManager.SelectedLight.range, 0.1f, 100f, "N1", range => { lightManager.SelectedLight.range = range; });
                                        if (lightManager.SelectedLight.type == LightType.Spot)
                                        {
                                            Slider("Spot Angle", lightManager.SelectedLight.spotAngle, 1f, 179f, "N1", angle => { lightManager.SelectedLight.spotAngle = angle; });
                                        }
                                    }
                                    GUILayout.Space(10);
                                    if (lightManager.UseAlloyLight && alloyLight.HasSpecularHighlight && null != alloyLight)
                                    {
                                        Slider("Specular Highlight", alloyLight.Radius, 0f, 1f, "N2", i => alloyLight.Radius = i);

                                        if (lightManager.SelectedLight.type == LightType.Point)
                                        {
                                            Slider("Length", alloyLight.Length, 0f, 1f, "N2", i => alloyLight.Length = i);
                                        }
                                    }
                                    if (showAdvanced)
                                    {
                                        Selection("Render Mode", lightManager.SelectedLight.light.renderMode, mode => lightManager.SelectedLight.light.renderMode        = mode);
                                        SelectionMask("Culling Mask", lightManager.SelectedLight.light.cullingMask, mask => lightManager.SelectedLight.light.cullingMask = mask);
                                    }
                                }
                                GUILayout.EndScrollView();
                                GUILayout.EndVertical();
                                GUILayout.FlexibleSpace();
                            }
                            else
                            {
                                Label("Selected light is disabled.", "");
                            }
                        }
                        else
                        {
                            Label("Select a light source on the left panel.", "");
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
示例#5
0
        internal static void Draw(GlobalSettings renderingSettings, LightManager lightManager, bool showAdvanced)
        {
            GUILayout.BeginVertical(GUIStyles.Skin.box);
            {
                if (showAdvanced)
                {
                    lightManager.UseAlloyLight = Toggle("Use Alloy Light", lightManager.UseAlloyLight);
                    renderingSettings.LightsUseLinearIntensity  = Toggle("Lights Use Linear Intensity", renderingSettings.LightsUseLinearIntensity);
                    renderingSettings.LightsUseColorTemperature = Toggle("Lights Use Color Temperature", renderingSettings.LightsUseColorTemperature);
                }
                GUILayout.BeginHorizontal(GUIStyles.Skin.box);
                {
                    GUILayout.BeginVertical(GUIStyles.Skin.box, GUILayout.Width(200), GUILayout.MaxWidth(250));
                    {
                        LightGroup(lightManager, "Directional Lights", LightSettings.LightType.Directional);
                        if (0 < lightManager.DirectionalLights.Count)
                        {
                            GUILayout.BeginVertical(GUIStyles.Skin.box);
                            dirLightScrollView = GUILayout.BeginScrollView(dirLightScrollView);
                            lightManager.DirectionalLights.ForEach(l => LightOverviewModule(lightManager, l));
                            GUILayout.FlexibleSpace();
                            GUILayout.EndScrollView();
                            GUILayout.EndVertical();
                        }
                        LightGroup(lightManager, "Point Lights", LightSettings.LightType.Point);
                        if (0 < lightManager.PointLights.Count)
                        {
                            GUILayout.BeginVertical(GUIStyles.Skin.box);
                            pointLightScrollView = GUILayout.BeginScrollView(pointLightScrollView);
                            lightManager.PointLights.ForEach(l => LightOverviewModule(lightManager, l));
                            GUILayout.FlexibleSpace();
                            GUILayout.EndScrollView();
                            GUILayout.EndVertical();
                        }
                        LightGroup(lightManager, "Spot Lights", LightSettings.LightType.Spot);
                        if (0 < lightManager.SpotLights.Count)
                        {
                            GUILayout.BeginVertical(GUIStyles.Skin.box);
                            spotLightScrollView = GUILayout.BeginScrollView(spotLightScrollView);
                            lightManager.SpotLights.ForEach(l => LightOverviewModule(lightManager, l));
                            GUILayout.FlexibleSpace();
                            GUILayout.EndScrollView();
                            GUILayout.EndVertical();
                        }
                    }
                    GUILayout.EndVertical();
                    GUILayout.Space(1);
                    inspectorScrollView = GUILayout.BeginScrollView(inspectorScrollView);
                    GUILayout.BeginVertical(GUIStyles.Skin.box);
                    {
                        if (null != lightManager.SelectedLight)
                        {
                            if (lightManager.SelectedLight.enabled)
                            {
                                AlloyAreaLight alloyLight = null;
                                if (lightManager.UseAlloyLight)
                                {
                                    alloyLight = lightManager.SelectedLight.light.GetComponent <AlloyAreaLight>();
                                }

                                Label(lightManager.SelectedLight.light.name, "", true);
                                GUILayout.Space(10);
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.BeginVertical();
                                    {
                                        Label("Colour", "", true);
                                        SliderColor("Colour", lightManager.SelectedLight.color, c => lightManager.SelectedLight.color = c);
                                        if (renderingSettings.LightsUseColorTemperature)
                                        {
                                            Slider("Temperature (K)", lightManager.SelectedLight.light.colorTemperature, 0f, 30000f, "N0", t => lightManager.SelectedLight.light.colorTemperature = t);
                                        }

                                        GUILayout.Space(10);
                                        Slider("Intensity", lightManager.SelectedLight.intensity, LightSettings.IntensityMin, LightSettings.IntensityMax, "N2", i => lightManager.SelectedLight.intensity = i);
                                        Slider("Indirect Multiplier", lightManager.SelectedLight.light.bounceIntensity, LightSettings.IntensityMin, LightSettings.IntensityMax, "N0", bi => lightManager.SelectedLight.light.bounceIntensity = bi);
                                        GUILayout.Space(10);
                                        Label("Shadows", "", true);
                                        Selection("Shadow Type", lightManager.SelectedLight.shadows, type => lightManager.SelectedLight.shadows = type);
                                        Slider("Strength", lightManager.SelectedLight.light.shadowStrength, 0f, 1f, "N2", strength => lightManager.SelectedLight.light.shadowStrength = strength);
                                        Selection("Resolution", lightManager.SelectedLight.light.shadowResolution, resolution => lightManager.SelectedLight.light.shadowResolution    = resolution, 2);
                                        Slider("Bias", lightManager.SelectedLight.light.shadowBias, 0f, 2f, "N3", bias => lightManager.SelectedLight.light.shadowBias = bias);
                                        Slider("Normal Bias", lightManager.SelectedLight.light.shadowNormalBias, 0f, 3f, "N2", nbias => lightManager.SelectedLight.light.shadowNormalBias = nbias);
                                        Slider("Near Plane", lightManager.SelectedLight.light.shadowNearPlane, 0f, 10f, "N2", np => lightManager.SelectedLight.light.shadowNearPlane      = np);
                                        GUILayout.Space(10);
                                        if (showAdvanced)
                                        {
                                            Selection("Render Mode", lightManager.SelectedLight.light.renderMode, mode => lightManager.SelectedLight.light.renderMode = mode);
                                            Label("Culling Mask", lightManager.SelectedLight.light.cullingMask.ToString());
                                        }

                                        if (lightManager.SelectedLight.type == LightType.Directional)
                                        {
                                            Vector3 rot = lightManager.SelectedLight.rotation;
                                            Slider("Vertical Rotation", rot.x, LightSettings.RotationXMin, LightSettings.RotationXMax, "N1", x => { rot.x = x; });
                                            Slider("Horizontal Rotation", rot.y, LightSettings.RotationYMin, LightSettings.RotationYMax, "N1", y => { rot.y = y; });

                                            if (rot != lightManager.SelectedLight.rotation)
                                            {
                                                lightManager.SelectedLight.rotation = rot;
                                            }
                                        }
                                        else
                                        {
                                            Slider("Light Range", lightManager.SelectedLight.range, 0.1f, 100f, "N1", range => { lightManager.SelectedLight.range = range; });
                                            if (lightManager.SelectedLight.type == LightType.Spot)
                                            {
                                                Slider("Spot Angle", lightManager.SelectedLight.spotAngle, 1f, 179f, "N1", angle => { lightManager.SelectedLight.spotAngle = angle; });
                                            }
                                        }
                                        GUILayout.Space(10);
                                        if (lightManager.UseAlloyLight && alloyLight.HasSpecularHighlight && null != alloyLight)
                                        {
                                            Slider("Specular Highlight", alloyLight.Radius, 0f, 1f, "N2", i => alloyLight.Radius = i);

                                            if (lightManager.SelectedLight.type == LightType.Point)
                                            {
                                                Slider("Length", alloyLight.Length, 0f, 1f, "N2", i => alloyLight.Length = i);
                                            }
                                        }
                                        GUILayout.Space(10);

                                        /* PCSS
                                         *  public Slider softnessSlider;
                                         *  public Text softnessText;
                                         *
                                         *  [Space(10f)]
                                         *  public Slider softnessFalloffSlider;
                                         *  public Text softnessFalloffText;
                                         *
                                         *  [Space(10f)]
                                         *  public Slider blockerSlider;
                                         *  public Text blockerText;
                                         *
                                         *  [Space(10f)]
                                         *  public Slider pcfSlider;
                                         *  public Text pcfText;
                                         *
                                         *  public void SetBlockerSamples (float samplesFloat)
                                         *  {
                                         *      int samples = Mathf.RoundToInt(samplesFloat);
                                         *      pcssScript.Blocker_SampleCount = samples;
                                         *      blockerText.text = string.Format("Blocker Samples: {0}", samples);
                                         *      pcssScript.UpdateShaderValues();
                                         *  }
                                         *
                                         *  public void SetPCFSamples (float samplesFloat)
                                         *  {
                                         *      int samples = Mathf.RoundToInt(samplesFloat);
                                         *      pcssScript.PCF_SampleCount = samples;
                                         *      pcfText.text = string.Format("PCF Samples: {0}", samples);
                                         *      pcssScript.UpdateShaderValues();
                                         *  }
                                         *
                                         *  public void SetSoftness (float softness)
                                         *  {
                                         *      pcssScript.Softness = softness;
                                         *      softnessText.text = string.Format("Softness: {0}", softness.ToString("N2"));
                                         *      pcssScript.UpdateShaderValues();
                                         *  }
                                         *
                                         *  public void SetSoftnessFalloff (float softnessFalloff)
                                         *  {
                                         *      pcssScript.SoftnessFalloff = softnessFalloff;
                                         *      softnessFalloffText.text = string.Format("Softness Falloff: {0}", softnessFalloff.ToString("N2"));
                                         *      pcssScript.UpdateShaderValues();
                                         *  }
                                         *
                                         *  PCSSLight script = target as PCSSLight;
                                         *  script.UpdateShaderValues();
                                         *
                                         *  if (script.Blocker_GradientBias < Mathf.Epsilon && QualitySettings.shadowCascades == 1)
                                         *  {
                                         *      EditorGUILayout.HelpBox("A 'Blocker Gradient Bias' of 0 seems to cause issues when not using shadow cascades. Any non-zero value should fix this.", MessageType.Error);
                                         *  }
                                         */
                                    }
                                    GUILayout.EndVertical();
                                }
                                GUILayout.EndHorizontal();
                            }
                            else
                            {
                                Label("Selected light is disabled.", "");
                            }
                        }
                        else
                        {
                            Label("Select a light source on the left panel.", "");
                        }
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndScrollView();
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
	// Use this for initialization
	void Start () {
        myLight = GetComponent<AlloyAreaLight>();
        perlinOffset = Random.Range(0.0f, 1.0f);
	}
示例#7
0
        internal static void Draw(GlobalSettings renderingSettings, LightManager lightManager, bool showAdvanced)
        {
            GUILayout.BeginVertical(GUIStyles.Skin.box);
            {
                if (showAdvanced)
                {
                    lightManager.UseAlloyLight = Toggle("Use Alloy Light", lightManager.UseAlloyLight);
                    renderingSettings.LightsUseLinearIntensity  = Toggle("Lights Use Linear Intensity", renderingSettings.LightsUseLinearIntensity);
                    renderingSettings.LightsUseColorTemperature = Toggle("Lights Use Color Temperature", renderingSettings.LightsUseColorTemperature);
                }
                GUILayout.BeginHorizontal(GUIStyles.Skin.box);
                {
                    lightScrollView = GUILayout.BeginScrollView(lightScrollView);
                    GUILayout.BeginVertical(GUIStyles.Skin.box, GUILayout.Width(200), GUILayout.MaxWidth(250));
                    {
                        LightGroup(lightManager, "Directional Lights", LightSettings.LightType.Directional);
                        GUILayout.Space(5);
                        lightManager.DirectionalLights.ForEach(l => LightOverviewModule(lightManager, l));
                        GUILayout.Space(10);
                        LightGroup(lightManager, "Point Lights", LightSettings.LightType.Point);
                        GUILayout.Space(5);
                        lightManager.PointLights.ForEach(l => LightOverviewModule(lightManager, l));
                        GUILayout.Space(10);
                        LightGroup(lightManager, "Spot Lights", LightSettings.LightType.Spot);
                        GUILayout.Space(5);
                        lightManager.SpotLights.ForEach(l => LightOverviewModule(lightManager, l));
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndScrollView();
                    GUILayout.Space(1);
                    inspectorScrollView = GUILayout.BeginScrollView(inspectorScrollView);
                    GUILayout.BeginVertical(GUIStyles.Skin.box);
                    {
                        if (selectedLight)
                        {
                            if (selectedLight.enabled)
                            {
                                AlloyAreaLight alloyLight = null;
                                if (lightManager.UseAlloyLight)
                                {
                                    alloyLight = selectedLight.GetComponent <AlloyAreaLight>();
                                }

                                GUILayout.Label(selectedLight.name, GUIStyles.boldlabel);
                                GUILayout.Space(10);
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.BeginVertical();
                                    {
                                        GUILayout.Label("Colour", GUIStyles.boldlabel);
                                        SliderColor("Colour", selectedLight.color, c => selectedLight.color = c);
                                        if (renderingSettings.LightsUseColorTemperature)
                                        {
                                            Slider("Temperature (K)", selectedLight.colorTemperature, 0f, 30000f, "N0", t => selectedLight.colorTemperature = t);
                                        }

                                        GUILayout.Space(10);
                                        Slider("Intensity", selectedLight.intensity, 0f, 8f, "N2", i => selectedLight.intensity = i);
                                        Slider("Indirect Multiplier", selectedLight.bounceIntensity, 0f, 8f, "N0", bi => selectedLight.bounceIntensity = bi);
                                        GUILayout.Space(10);
                                        GUILayout.Label("Shadows", GUIStyles.boldlabel);
                                        Selection("Shadow Type", selectedLight.shadows, type => selectedLight.shadows = type);
                                        Slider("Strength", selectedLight.shadowStrength, 0f, 1f, "N2", strength => selectedLight.shadowStrength = strength);
                                        Selection("Resolution", selectedLight.shadowResolution, resolution => selectedLight.shadowResolution    = resolution, 2);
                                        Slider("Bias", selectedLight.shadowBias, 0f, 2f, "N3", bias => selectedLight.shadowBias = bias);
                                        Slider("Normal Bias", selectedLight.shadowNormalBias, 0f, 3f, "N2", nbias => selectedLight.shadowNormalBias = nbias);
                                        Slider("Near Plane", selectedLight.shadowNearPlane, 0f, 10f, "N2", np => selectedLight.shadowNearPlane      = np);
                                        GUILayout.Space(10);
                                        if (showAdvanced)
                                        {
                                            Selection("Render Mode", selectedLight.renderMode, mode => selectedLight.renderMode = mode);
                                            Label("Culling Mask", selectedLight.cullingMask.ToString());
                                        }

                                        if (selectedLight.type == LightType.Directional)
                                        {
                                            Vector3 rot = selectedLight.transform.eulerAngles;
                                            rot.x = Mathf.DeltaAngle(0f, rot.x);
                                            if (rot.x > 180f)
                                            {
                                                rot.x -= 360f;
                                            }
                                            rot.y = Mathf.DeltaAngle(0f, rot.y);
                                            if (rot.y > 180f)
                                            {
                                                rot.y -= 360f;
                                            }
                                            Slider("Vertical Rotation", rot.x, LightSettings.RotationXMin, LightSettings.RotationXMax, "N1", x => { rot.x = x; });
                                            Slider("Horizontal Rotation", rot.y, LightSettings.RotationYMin, LightSettings.RotationYMax, "N1", y => { rot.y = y; });
                                            if (rot != selectedLight.transform.eulerAngles)
                                            {
                                                selectedLight.transform.eulerAngles = rot;
                                            }
                                        }
                                        else
                                        {
                                            Slider("Light Range", selectedLight.range, 0.1f, 100f, "N1", range => { selectedLight.range = range; });
                                            if (selectedLight.type == LightType.Spot)
                                            {
                                                Slider("Spot Angle", selectedLight.spotAngle, 1f, 179f, "N1", angle => { selectedLight.spotAngle = angle; });
                                            }
                                        }

                                        if (lightManager.UseAlloyLight && alloyLight.HasSpecularHighlight && null != alloyLight)
                                        {
                                            Slider("Specular Highlight", alloyLight.Radius, 0f, 1f, "N2", i => alloyLight.Radius = i);

                                            if (selectedLight.type == LightType.Point)
                                            {
                                                Slider("Length", alloyLight.Length, 0f, 1f, "N2", i => alloyLight.Length = i);
                                            }
                                        }
                                    }
                                    GUILayout.EndVertical();
                                }
                                GUILayout.EndHorizontal();
                            }
                            else
                            {
                                GUILayout.Label("Selected light is disabled.");
                            }
                        }
                        else
                        {
                            GUILayout.Label("Select a light source on the left panel.");
                        }
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndScrollView();
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }