Ejemplo n.º 1
0
    /// <summary>
    /// Finds Or Creates The Main Camera On the Scene.
    /// </summary>
    public static void FindOrCreate()
    {
        GameObject tempMainCamera;

        if (Camera.main != null)
        {
            tempMainCamera = Camera.main.gameObject;
            tempMainCamera.GetComponent <Camera>().clearFlags = CameraClearFlags.Depth;
            if (GameController.instance.gameState == GlobalInfo.GameState.MENU)
            {
                tempMainCamera.AddComponent <MainMenuCameraController>();
            }
        }
        else
        {
            tempMainCamera = new GameObject("Main Camera");
            tempMainCamera.AddComponent <Camera>();
            tempMainCamera.AddComponent <GUILayer>();
            tempMainCamera.AddComponent <AudioListener>();
            tempMainCamera.tag = "MainCamera";
        }

        SkyboxCameraController.CreateSkyboxCamera();

        if (GameController.instance.gameState == GlobalInfo.GameState.INGAME)
        {
            GameObject tempLight = new GameObject("Directional Light");
            tempLight.transform.rotation = Quaternion.Euler(45.0f, -135.0f, 0.0f);
            tempLight.AddComponent <Light>();
            Light lightDetails = tempLight.GetComponent <Light>();
            lightDetails.type      = LightType.Directional;
            lightDetails.intensity = 0.50f;

            lightDetails.shadows            = LightShadows.Soft;
            lightDetails.shadowStrength     = 0.75f;
            lightDetails.shadowBias         = 0.05f;
            lightDetails.shadowSoftness     = 5.0f;
            lightDetails.shadowSoftnessFade = 2.0f;

            tempMainCamera.GetComponent <Camera>().clearFlags = CameraClearFlags.Depth;
            tempMainCamera.AddComponent <MainCameraController>();
        }
    }
Ejemplo n.º 2
0
 private void Awake()
 {
     instance = this;
 }