예제 #1
0
 public QuadtreeGizmosEnumerator(hwmQuadtree <T> quadtree)
 {
     m_Quadtree    = quadtree;
     m_Current     = m_Quadtree.GetRootNode();
     m_GizmosColor = Color.black;
     m_GizmosZ     = 0;
     m_GizomosDisplayChilderElement = true;
     m_LastNodes    = new Stack <hwmQuadtree <T> .Node>();
     m_ChilderIndex = NOTSET_CHILDER_INDEX;
 }
예제 #2
0
        public void OnGUI()
        {
            while (m_Current == null)
            {
                if (m_LastNodes.Count > 0)
                {
                    m_Current = m_LastNodes.Pop();
                }
                else
                {
                    m_Current = m_Quadtree.GetRootNode();
                    break;
                }
            }

            if (m_Current == null)
            {
                EditorGUILayout.HelpBox("not found any node", MessageType.Error);
                return;
            }

            hwmQuadtree <T> .Node displayNode = GetDisplayNode();
            EditorGUILayout.LabelField("Depth:", displayNode.GetDepth().ToString());
            EditorGUILayout.LabelField("Element Count:", displayNode.GetElements().Count.ToString());
            EditorGUILayout.LabelField("Element Count In Self&Childers :", displayNode.GetAllElementCount().ToString());

            EditorGUILayout.Space();
            if (m_Current.GetParent() == null &&
                m_ChilderIndex == NOTSET_CHILDER_INDEX)
            {
                GUILayout.Button("No Parent");
            }
            else if (GUILayout.Button("Parent"))
            {
                if (m_ChilderIndex != NOTSET_CHILDER_INDEX)
                {
                    m_ChilderIndex = NOTSET_CHILDER_INDEX;
                }
                else
                {
                    m_Current = m_LastNodes.Pop();
                }
            }
            EditorGUILayout.BeginHorizontal();
            OnGUI_ChildersButton(hwmQuadtreeChilderNodeIndex.LeftUp);
            OnGUI_ChildersButton(hwmQuadtreeChilderNodeIndex.RightUp);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            OnGUI_ChildersButton(hwmQuadtreeChilderNodeIndex.LeftDown);
            OnGUI_ChildersButton(hwmQuadtreeChilderNodeIndex.RightDown);
            EditorGUILayout.EndHorizontal();
            if (m_Current.IsLeaf() || m_ChilderIndex == NOTSET_CHILDER_INDEX)
            {
                GUILayout.Button("Cant Enter Childer");
            }
            else if (GUILayout.Button("Enter Childer: " + m_ChilderIndex.ToString()))
            {
                m_LastNodes.Push(m_Current);
                m_Current      = m_Current.GetChilder(m_ChilderIndex);
                m_ChilderIndex = NOTSET_CHILDER_INDEX;
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Gizmos");
            m_GizmosColor = EditorGUILayout.ColorField("Color", m_GizmosColor);
            m_GizmosZ     = EditorGUILayout.FloatField("Z", m_GizmosZ);
            m_GizomosDisplayChilderElement = EditorGUILayout.Toggle("Display Childer Element", m_GizomosDisplayChilderElement);

            if (GUI.changed)
            {
                GetWindow <SceneView>().Focus();
            }
        }