protected override void Awake()
        {
            if ((int)PlanetManager.DebugLevel > 0)
            {
                Debug.Log("GasPlanetStatic.cs: Awake()");
            }
            if ((int)PlanetManager.DebugLevel > 0)
            {
                Debug.Log("- PlanetVersion: " + PLANET_VERSION);
            }

            // Set Shader property int IDs for increased performance when updating property parameters
            _shaderID_LocalStarPosition         = Shader.PropertyToID("_LocalStarPosition");
            _shaderID_LocalStarColor            = Shader.PropertyToID("_LocalStarColor");
            _shaderID_LocalStarIntensity        = Shader.PropertyToID("_LocalStarIntensity");
            _shaderID_LocalStarAmbientIntensity = Shader.PropertyToID("_LocalStarAmbientIntensity");

            // Ensure that there is a LocalStar in the scene.
            if (FindObjectOfType <LocalStar>() == null)
            {
                Debug.LogWarning("There is no LocalStar in the scene. Planet will not be lit. Create a game object and add the LocalStar component. The position of the game object will be the light source.");
            }

            // Get reference to the MeshFilter component
            meshFilter            = gameObject.GetComponent <MeshFilter>();
            meshFilter.sharedMesh = ProceduralOctahedron.Create(meshSubdivisions, 5.0f);

            // Get reference to MeshRenderer Component
            _meshRenderer = gameObject.GetComponent <MeshRenderer>();

            // Update shader for planet lighting
            UpdateShaderLocalStar(true);
        }
示例#2
0
        protected override void Awake()
        {
            if ((int)PlanetManager.DebugLevel > 0)
            {
                Debug.Log("SolidPlanetStatic.cs: Awake()");
            }
            if ((int)PlanetManager.DebugLevel > 0)
            {
                Debug.Log("- PlanetVersion: " + PLANET_VERSION);
            }

            // Set Shader property int IDs for increased performance when updating property parameters
            _shaderID_LocalStarPosition         = Shader.PropertyToID("_LocalStarPosition");
            _shaderID_LocalStarColor            = Shader.PropertyToID("_LocalStarColor");
            _shaderID_LocalStarIntensity        = Shader.PropertyToID("_LocalStarIntensity");
            _shaderID_LocalStarAmbientIntensity = Shader.PropertyToID("_LocalStarAmbientIntensity");

            // Ensure that there is a LocalStar in the scene.
            if (FindObjectOfType <LocalStar>() == null)
            {
                Debug.LogWarning("There is no LocalStar in the scene. Planet will not be lit. Create a game object and add the LocalStar component. The position of the game object will be the light source.");
            }

            // Get reference to the MeshFilter component
            meshFilter            = gameObject.GetComponent <MeshFilter>();
            meshFilter.sharedMesh = ProceduralOctahedron.Create(meshSubdivisions, 5.0f);

            _externalAtmosphere = transform.Find("ExternalAtmosphere").gameObject;
            if (_externalAtmosphere == null)
            {
                Debug.LogError("Planet has no atmosphere game object. You could try to rebake this planet from the original procedural planet or the JSON file in the asset folder for this static planet.");
            }
            _externalAtmosphereMeshFilter = _externalAtmosphere.GetComponent <MeshFilter>();
            // Use the planet's procedural octahedron sphere mesh as the atmosphere mesh as well
            _externalAtmosphereMeshFilter.sharedMesh = meshFilter.sharedMesh;
            _externalAtmosphereRenderer = _externalAtmosphere.GetComponent <MeshRenderer>();

            // Get reference to MeshRenderer Component
            _meshRenderer = gameObject.GetComponent <MeshRenderer>();

            // Update shader for planet lighting
            UpdateShaderLocalStar(true);
        }