Esempio n. 1
0
    /// <summary>
    /// Initialize each element
    /// </summary>
    public void SetupElements()
    {
        if (parallaxCamera == null)
        {
            parallaxCamera = Camera.main;
            if (parallaxCamera == null)
            {
                Debug.LogError("Cannot run parallax without a camera");
                return;
            }
        }

        for (int i = 0; i < Elements.Count; i++)
        {
            FreeParallaxElement e = Elements[i];
            if (e.GameObjects == null || e.GameObjects.Count == 0)
            {
                Debug.LogError("No game objects found at element index " + i.ToString() + ", be sure to set at least one game object for each element in the parallax");
                return;
            }
            foreach (GameObject obj in e.GameObjects)
            {
                if (obj == null)
                {
                    Debug.LogError("Null game object found at element index " + i.ToString());
                }
            }

            e.SetupState(this, parallaxCamera, i);
            e.SetupScale(this, parallaxCamera, i);
            e.SetupPosition(this, parallaxCamera, i);
        }
    }
Esempio n. 2
0
    private void SetupElementAtIndex(int i)
    {
        FreeParallaxElement e = Elements[i];

        if (e.GameObjects == null || e.GameObjects.Count == 0)
        {
            Debug.LogError("No game objects found at element index " + i.ToString() + ", be sure to set at least one game object for each element in the parallax");
            return;
        }
        foreach (GameObject obj in e.GameObjects)
        {
            if (obj == null)
            {
                Debug.LogError("Null game object found at element index " + i.ToString());
                return;
            }
        }

        e.SetupState(this, parallaxCamera, i);
        e.SetupScale(this, parallaxCamera, i);
        e.SetupPosition(this, parallaxCamera, i);
    }