Наследование: MonoBehaviour
Пример #1
0
    public void SetUpBackground()
    {
        var count = backgroundLayerParameters.Length;

        layerUVs = new ScrollUV[count];

        // controls layer star size
        backgroundLayerParameters.ToList().ForEach(param => param.size.ControlRange());

        // loops through all of the layer parameters
        for (int i = 0; i < count; i++)
        {
            // creates layer object inside this hierarchy
            var layer = Instantiate(quadPrefab, new Vector3(0, 0, i), transform.rotation, transform);
            layer.name  = $@"Layer {i + 1}";
            layerUVs[i] = layer.GetComponent <ScrollUV>();
            // sets texture of the cutout material and parallax multiplier of the quad
            layerUVs[i].texture  = SetUpLayer(backgroundLayerParameters[i]);
            layerUVs[i].parallax = backgroundLayerParameters[i].parallaxEffect;
        }

        // instantiates static background
        var tempBackground = Instantiate(background, new Vector3(0, 0, count + 1), transform.rotation, transform);

        tempBackground.name   = "Background";
        backgroundUV          = tempBackground.GetComponent <ScrollUV>();
        backgroundUV.parallax = 0f;
    }
Пример #2
0
 void Start()
 {
     gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();
     uvOffset    = GameObject.Find("StarFieldFG").GetComponent <ScrollUV>();
 }