public static void initMod()
        {
            Debug.Log("init of EnhancedSky standalone");

            gameobjectEnhancedSky = new GameObject("EnhancedSkyController");

            componentPresetContainer = gameobjectEnhancedSky.AddComponent <PresetContainer>() as PresetContainer;
            SetPresetContainerValues(componentPresetContainer);
            PresetContainer.Instance = componentPresetContainer;

            componentSkyManager = gameobjectEnhancedSky.AddComponent <SkyManager>() as SkyManager;
            SkyManager.instance = componentSkyManager;

            componentCloudGenerator = gameobjectEnhancedSky.AddComponent <CloudGenerator>() as CloudGenerator;

            componentSkyManager.ModSelf = mod;

            starMaskMat = new Material(shaderDepthMask);
            skyObjMat   = new Material(shaderUnlitAlphaWithFade);

            componentSkyManager.StarMaskMat = starMaskMat;
            componentSkyManager.SkyObjMat   = skyObjMat;
            componentSkyManager.StarsMat    = starsMat;
            componentSkyManager.SkyMat      = skyMat;

            if (containerPrefab)
            {
                GameObject container = Instantiate(containerPrefab) as GameObject;
                container.transform.SetParent(GameManager.Instance.ExteriorParent.transform, true);

                componentSkyManager.Container = container;

                //container.AddComponent<MoonController>();
                //container.AddComponent<AmbientFogLightController>();

                //container.transform.Find("SkyCam").gameObject.AddComponent<SkyCam>();
                //container.transform.Find("Stars").Find("StarParticles").gameObject.AddComponent<StarController>();
                //container.transform.Find("Rotator").gameObject.AddComponent<RotationScript>();
                //container.transform.Find("cloudPrefab").gameObject.AddComponent<Cloud>();

                GameObject goParticles = container.transform.Find("Stars").Find("StarParticles").gameObject;
                goParticles.GetComponent <ParticleSystemRenderer>().sharedMaterial = new Material(shaderUnlitAlphaWithFade);

                GameObject goSun = container.transform.Find("Rotator").Find("Sun").gameObject;
                goSun.GetComponent <LensFlare>().flare = sunFlare;
                goSun.GetComponent <Light>().intensity = sunSize;
            }
            else
            {
                throw new System.NullReferenceException();
            }

            componentSkyManager.ToggleEnhancedSky(true);
            componentSkyManager.UseSunFlare  = enableSunFlare;
            componentSkyManager.cloudQuality = cloudQuality;
            componentSkyManager.SkyObjectSizeChange(0); // set normal size
        }
Ejemplo n.º 2
0
            public static string Execute(params string[] args)
            {
                SkyManager skyMan = SkyManager.instance;

                if (skyMan == null)
                {
                    return("SkyManager instance not found");
                }
                else
                {
                    skyMan.ToggleEnhancedSky(!skyMan.EnhancedSkyCurrentToggle);
                    return(string.Format("SkyManager toggled; current state on: {0}", skyMan.EnhancedSkyCurrentToggle));
                }
            }
        public override void OnInspectorGUI()
        {
            SkyManager skyMan = (SkyManager)target;


            DrawDefaultInspector();

            if (EditorApplication.isPlaying)
            {
                if (GUILayout.Button("Toggle Enhanced Sky"))
                {
                    skyMan.EnhancedSkyCurrentToggle = !skyMan.EnhancedSkyCurrentToggle;
                    skyMan.ToggleEnhancedSky(skyMan.EnhancedSkyCurrentToggle);
                }
                if (GUILayout.Button("Toggle Sun Flare"))
                {
                    skyMan.UseSunFlare = !skyMan.UseSunFlare;
                }

                if (GUILayout.Button("Apply normal cloud texture"))
                {
                    Cloud cloud = GameObject.FindObjectOfType <Cloud>();
                    if (cloud != null)
                    {
                        cloud.GetNewTexture(false);
                    }
                }

                if (GUILayout.Button("Apply overcast cloud texture"))
                {
                    Cloud cloud = GameObject.FindObjectOfType <Cloud>();
                    if (cloud != null)
                    {
                        cloud.GetNewTexture(true);
                    }
                }

                if (GUILayout.Button("Toggle Weather"))          //WeatherManager doesn't like this before the game is properly started
                {
                    if (skyMan.IsOvercast)
                    {
                        skyMan.weatherMan.ClearAllWeather();
                    }
                    else
                    {
                        skyMan.weatherMan.SetRainOvercast(true);
                    }


                    Debug.Log("Is Overcast: " + skyMan.weatherMan.IsOvercast);
                }


                skyObjectSizeSelected = (SkyObjectSize)EditorGUILayout.EnumPopup("Sky Object Size", skyObjectSizeSelected);

                if (GUILayout.Button("Update Setting"))
                {
                    skyMan.SkyObjectSizeChange(skyObjectSizeSelected);
                }
            }
        }