// Use this for initialization void Start() { _transform = GetComponent <Transform>(); _lastMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); _backgroundLayers = null; _currentBackground = null; _parallaxingManager = new Parallaxing(); _frameCounter = 0; Init(0); }
// Use this for initialization of new background public void Init(int index) { if (_currentBackground != null) { Destroy(_currentBackground); } Transform[] bgTransforms = new Transform[BackgroundLayersPrefab.Length]; _currentBackground = (GameObject)Instantiate(BackgroundLayersPrefab[index], Vector3.zero, Quaternion.identity); _backgroundLayers = _currentBackground.GetComponent <BackgroundLayers>(); if (_backgroundLayers == null) { Debug.LogError("Error: invalid background prefab. At: " + index); return; } _currentBackground.transform.parent = _transform; }