Beispiel #1
0
        protected void SetNodePosition(ParallaxNode node)
        {
            Vector3 pos = m_Transform.localPosition;

            float x = -pos.x + pos.x * node.ratio.x + node.offset.x;
            float y = -pos.y + pos.y * node.ratio.y + node.offset.y;

            node.setPosition(x, y);
        }
Beispiel #2
0
        public void AddNode(GameObject obj, Vector2 ratio, Vector2 offset)
        {
            ParallaxNode node = obj.GetComponent <ParallaxNode>();

            if (node == null)
            {
                node = obj.AddComponent <ParallaxNode>();
            }

            node.ratio  = ratio;
            node.offset = offset;

            AddNode(obj);
        }
Beispiel #3
0
        public void AddNode(GameObject obj)
        {
            if (obj.activeInHierarchy)
            {
                ParallaxNode node = obj.GetComponent <ParallaxNode>();
                if (node != null)
                {
                    if (node.transform.parent != m_Transform)
                    {
                        node.transform.SetParent(m_Transform);
                    }

                    SetNodePosition(node);

                    m_Nodes.Add(node);
                }
            }
        }
Beispiel #4
0
 public void RemoveNode(ParallaxNode node)
 {
     m_Nodes.Remove(node);
     node.transform.SetParent(null);
 }