Example #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);
        }
    }
Example #2
0
 /// <summary>
 /// Add a new element to the parallax
 /// </summary>
 /// <param name="e">Element to add</param>
 public void AddElement(FreeParallaxElement e)
 {
     if (Elements == null)
     {
         Elements = new List<FreeParallaxElement>();
     }
     int i = Elements.Count;
     Elements.Add(e);
     SetupElementAtIndex(i);
 }
Example #3
0
    /// <summary>
    /// Add a new element to the parallax
    /// </summary>
    /// <param name="e">Element to add</param>
    public void AddElement(FreeParallaxElement e)
    {
        if (Elements == null)
        {
            Elements = new List <FreeParallaxElement>();
        }
        int i = Elements.Count;

        Elements.Add(e);
        SetupElementAtIndex(i);
    }
Example #4
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);
    }