Beispiel #1
0
    private void Awake()
    {
        this.backgroundGO = CreateRoot();

        //this.clearCameraData = CreateClearCamera(
        //    this.backgroundGO.transform, this.clearColor);
        CreateClearCamera(this.backgroundGO.transform, this.clearColor);

        this.backgroundCameraData0 = CreateBackgroundCamera(
            "VLBackgroundCamera0", this.backgroundGO.transform,
            this.backgroundLayer);

        this.backgroundMeshData0 = CreateBackgroundMesh(
            "VLBackgroundMesh0", this.backgroundCameraData0.go.transform,
            this.backgroundLayer, this.imageMaterial);
    }
Beispiel #2
0
    private static BackgroundCameraData CreateBackgroundCamera(
        string name, Transform parentTransform, int backgroundLayer)
    {
        BackgroundCameraData data = new BackgroundCameraData();

        data.go = new GameObject(name);
        data.go.transform.parent = parentTransform;

        data.camera             = data.go.AddComponent <Camera>();
        data.camera.depth       = 1;                    // Render after clearCamera
        data.camera.cullingMask = 1 << backgroundLayer; // Render only the background image

        // Clear nothing, because the clearCamera already cleared the screen
        data.camera.clearFlags = CameraClearFlags.Nothing;

        // Use an orthographic projection
        data.camera.orthographic     = true;
        data.camera.orthographicSize = 0.375f;
        data.camera.nearClipPlane    = 0.01f;
        data.camera.farClipPlane     = 1.0f;

        return(data);
    }