Exemplo n.º 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);
    }
Exemplo n.º 2
0
    private static BackgroundMeshData CreateBackgroundMesh(string name,
                                                           Transform parentTransform, int backgroundLayer, Material material)
    {
        BackgroundMeshData data = new BackgroundMeshData();

        // Create GameObject
        data.go = new GameObject(name);
        data.go.transform.parent     = parentTransform;
        data.go.transform.localScale =
            new Vector3(1.0f, 0.75f, 1.0f);
        data.go.layer = backgroundLayer;

        // Create MeshFilter
        data.meshFilter      = data.go.AddComponent <MeshFilter>();
        data.mesh            = CreateQuadMesh();
        data.meshFilter.mesh = data.mesh;

        // Create MeshRenderer
        data.meshRenderer = data.go.AddComponent <MeshRenderer>();
        data.meshRenderer.shadowCastingMode =
            UnityEngine.Rendering.ShadowCastingMode.Off;
        data.meshRenderer.receiveShadows = false;
#if UNITY_5_4_OR_NEWER
        data.meshRenderer.lightProbeUsage =
            UnityEngine.Rendering.LightProbeUsage.Off;
#else
        data.meshRenderer.useLightProbes = false;
#endif
        data.meshRenderer.reflectionProbeUsage =
            UnityEngine.Rendering.ReflectionProbeUsage.Off;

        // Create texture (will be set properly later)
        data.texture     = Texture2D.blackTexture;
        data.textureData = new byte[1];

        // Create Material
        data.material = new Material(material);

        // Use texture
        data.material.mainTexture = data.texture;

        // Use material
        data.meshRenderer.material = data.material;

        return(data);
    }