Ejemplo n.º 1
0
        public TreeView3DItem CreateItem(TreeView3DItem parent, GameObject visibleItem, bool hasParentTransform = false)
        {
            GameObject     ga = hasParentTransform?visibleItem: new GameObject("subItem");
            TreeView3DItem li = ga.AddComponent <TreeView3DItem>();

            li.tv3d = this;
            if (parent != null)
            {
                li.ParentItem         = parent;
                li.transform.position = parent.transform.position;
                li.transform.parent   = parent.transform;
                parent.Children.Add(li);
            }
            else
            {
                li.defaultScale     = childObjectScale * transform.localScale;
                li.transform.parent = this.transform;
            }
            if (!hasParentTransform)
            {
                visibleItem.transform.parent        = li.transform;
                visibleItem.transform.localPosition = Vector3.zero;
            }
            items.Add(li);
            li.parentDistance = this.parentDistance;
            return(li);
        }
Ejemplo n.º 2
0
 public void CreateChildren(TreeView3DItem parent, List <GameObject> children = null)
 {
     if (children != null)
     {
         foreach (var child in children)
         {
             TreeView3DItem c = CreateItem(parent, child);
         }
     }
 }
Ejemplo n.º 3
0
        void SetSelection(GameObject selectedItem)
        {
            GameObject parent = selectedItem.transform.parent.gameObject;

            if (parent != null)
            {
                TreeView3DItem tvItem = parent.GetComponentInChildren <TreeView3DItem>();
                foreach (var child in items)
                {
                    child.SetSelected(child == tvItem);
                }
            }
        }
Ejemplo n.º 4
0
        public static void CheckDistance(TreeView3DItem fromObject, TreeView3DItem toObject, float distance, bool minDistance = false)
        {
            Vector3 direction = fromObject.transform.position - toObject.transform.position;

            if (direction.magnitude == 0)
            {
                direction = Vector3.one;
            }
            if (!minDistance || direction.magnitude < distance)
            {
                direction.Normalize();
                fromObject.transform.position = Vector3.Lerp(fromObject.transform.position, toObject.transform.position + direction * distance, Time.deltaTime);
            }
            //
            fromObject.transform.position = Vector3.Lerp(fromObject.transform.position, sDrift, 0.001f * Time.deltaTime);
        }