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); }
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); }
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); } } }
public void RemoveNode(ParallaxNode node) { m_Nodes.Remove(node); node.transform.SetParent(null); }