public override void OnInspectorGUI()
        {
            cycle.Profile = JEditorCommon.ScriptableObjectField <JDayNightCycleProfile>("Profile", cycle.Profile);
            profile       = cycle.Profile;
            if (cycle.Profile == null)
            {
                return;
            }

            DrawSceneReferencesGUI();
            DrawTimeGUI();
            EditorGUI.BeginChangeCheck();
            DrawSkyGUI();
            DrawStarsGUI();
            DrawSunGUI();
            DrawMoonGUI();
            DrawHorizonCloudGUI();
            DrawOverheadCloudGUI();
            DrawDetailOverlayGUI();
            DrawEnvironmentReflectionGUI();
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(profile);
            }
        }
        public void AddProperty(JAnimatedProperty p, bool setDefaultValue = true)
        {
            if (setDefaultValue)
            {
                JDayNightCycleProfile defaultProfile = JJupiterSettings.Instance.DefaultDayNightCycleProfile;
                if (defaultProfile != null)
                {
                    JAnimatedProperty defaultProp = defaultProfile.AnimatedProperties.Find(p0 => p0.Name != null && p0.Name.Equals(p.Name));
                    if (defaultProp != null)
                    {
                        p.Curve    = defaultProp.Curve;
                        p.Gradient = defaultProp.Gradient;
                    }
                }
            }

            AnimatedProperties.Add(p);
        }
 private void OnEnable()
 {
     cycle   = target as JDayNightCycle;
     profile = cycle.Profile;
 }
Exemple #4
0
        private void SetupSkyMaterial()
        {
            if (Profile == null)
            {
                RenderSettings.skybox = JJupiterSettings.Instance.DefaultSkybox;
                return;
            }
            RenderSettings.skybox = Profile.Material;

            Profile.Material.SetTexture(JMat.NOISE_TEX, JJupiterSettings.Instance.NoiseTexture);
            Profile.Material.SetTexture(JMat.CLOUD_TEX, Profile.CustomCloudTexture ? Profile.CustomCloudTexture : JJupiterSettings.Instance.CloudTexture);

            if (Profile.EnableSun)
            {
                if (SunLightSource != null)
                {
                    JDayNightCycleProfile dncProfile = DNC ? DNC.Profile : null;
                    bool isSunLightColorOverridden   = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.SunLightColor));
                    if (!isSunLightColorOverridden)
                    {
                        SunLightSource.color = Profile.SunLightColor;
                    }
                    bool isSunLightIntensityOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.SunLightIntensity));
                    if (!isSunLightIntensityOverridden)
                    {
                        SunLightSource.intensity = Profile.SunLightIntensity;
                    }
                }

                Vector3 sunDirection = SunLightSource ? SunLightSource.transform.forward : DefaultSunDirection;
                if (Profile.UseBakedSun)
                {
                    Matrix4x4 sunRotationMatrix = Matrix4x4.Rotate(
                        Quaternion.FromToRotation(sunDirection, DefaultSunDirection));
                    Profile.Material.SetMatrix(JMat.SUN_ROTATION_MATRIX, sunRotationMatrix);
                }
                else
                {
                    Matrix4x4 positionToSunUV = Matrix4x4.TRS(
                        -sunDirection,
                        Quaternion.LookRotation(sunDirection),
                        Profile.SunSize * Vector3.one).inverse;
                    Profile.Material.SetVector(JMat.SUN_DIRECTION, sunDirection);
                    Profile.Material.SetMatrix(JMat.SUN_TRANSFORM_MATRIX, positionToSunUV);
                }
            }

            if (Profile.EnableMoon)
            {
                if (MoonLightSource != null)
                {
                    JDayNightCycleProfile dncProfile = DNC ? DNC.Profile : null;
                    bool isMoonLightColorOverridden  = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.MoonLightColor));
                    if (!isMoonLightColorOverridden)
                    {
                        MoonLightSource.color = Profile.MoonLightColor;
                    }
                    bool isMoonLightIntensityOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.MoonLightIntensity));
                    if (!isMoonLightIntensityOverridden)
                    {
                        MoonLightSource.intensity = Profile.MoonLightIntensity;
                    }
                }

                Vector3 moonDirection = MoonLightSource ? MoonLightSource.transform.forward : DefaultMoonDirection;
                if (Profile.UseBakedMoon)
                {
                    Matrix4x4 moonRotationMatrix = Matrix4x4.Rotate(
                        Quaternion.FromToRotation(moonDirection, DefaultMoonDirection));
                    Profile.Material.SetMatrix(JMat.MOON_ROTATION_MATRIX, moonRotationMatrix);
                }
                else
                {
                    Matrix4x4 positionToMoonUV = Matrix4x4.TRS(
                        -moonDirection,
                        Quaternion.LookRotation(moonDirection),
                        Profile.MoonSize * Vector3.one).inverse;
                    Profile.Material.SetVector(JMat.MOON_DIRECTION, moonDirection);
                    Profile.Material.SetMatrix(JMat.MOON_TRANSFORM_MATRIX, positionToMoonUV);
                }
            }
        }
 public static JDayNightCycleProfileInspectorDrawer Create(JDayNightCycleProfile instance)
 {
     return(new JDayNightCycleProfileInspectorDrawer(instance));
 }
 private JDayNightCycleProfileInspectorDrawer(JDayNightCycleProfile instance)
 {
     this.instance = instance;
 }
Exemple #7
0
 private void OnEnable()
 {
     instance = target as JDayNightCycleProfile;
 }