Exemple #1
0
        void Visualize(RigVisualizer visualizer)
        {
            MyHandles.DragHandleResult result;
            MyHandles.DragHandle(visualizer.GetHashCode(), visualizer.transform.position, Quaternion.identity, .1f, Handles.DotHandleCap, Color.green, out result);
            GUI.color = Color.blue;
            if (RigVisualizer.selected == visualizer)
            {
                GUI.color = Color.green;
            }

            Handles.Label(visualizer.transform.position, new GUIContent(nodeTexture), handleStyle);


            if (result == MyHandles.DragHandleResult.LMBClick)
            {
                RigVisualizer.selected = visualizer;
            }

            if (visualizer.children == null || (visualizer.children.Length > 0 && visualizer.children[0] == null))
            {
                visualizer.Init();
            }
            for (int i = 0; i < visualizer.children.Length; i++)
            {
                Visualize(visualizer.children[i]);
            }
        }
Exemple #2
0
        void OnEnable()
        {
            if (!visualizer)
            {
                visualizer = ((RigVisualizer)target);
            }
            nodeTexture = Resources.Load <Texture>("Handle");
            Debug.Log(nodeTexture);
            if (nodeTexture == null)
            {
                nodeTexture = EditorGUIUtility.whiteTexture;
            }
            handleStyle.alignment = TextAnchor.MiddleCenter;

            handleStyle.fixedWidth  = 20;
            handleStyle.fixedHeight = 20;
        }
 public void Init()
 {
     if (!transform.parent || !(transform.parent.GetComponent <RigVisualizer>()))
     {
         root = this;
     }
     children = new RigVisualizer[transform.childCount];
     Debug.Log(children.Length);
     for (int i = 0; i < children.Length; i++)
     {
         var child = transform.GetChild(i);
         children[i] = child.GetComponent <RigVisualizer>();
         if (!children[i])
         {
             children[i] = child.gameObject.AddComponent <RigVisualizer>();
         }
         children[i].Init();
     }
 }