示例#1
0
 private void OnEnable()
 {
     if (Application.isPlaying)
     {
         return;
     }
     m_CreatureRoot = GetComponentInChildren <CreatureRoot>();
     m_LocationRoot = GetComponentInChildren <LocationRoot>();
     m_TeleportRoot = GetComponentInChildren <TeleportRoot>();
     m_LeapRoot     = GetComponentInChildren <LeapRoot>();
     m_TriggerRoot  = GetComponentInChildren <TriggerRoot>();
     m_TreasureRoot = GetComponentInChildren <TreasureRoot>();
     m_MineralRoot  = GetComponentInChildren <MineralRoot>();
     if (m_LeapRoot == null)
     {
         CreateLeapRoot();
     }
     if (m_TriggerRoot == null)
     {
         CreateTriggerRoot();
     }
     if (m_TreasureRoot == null)
     {
         CreateTreasureRoot();
     }
     if (m_MineralRoot == null)
     {
         CreateMineralRoot();
     }
 }
示例#2
0
        /// <summary>
        /// 刷新LocationRoot ui
        /// </summary>
        private void RefreashLocationRootUI(LocationRoot root)
        {
            if (root == null)
            {
                return;
            }

            m_ContentCache.Clear();
            m_ContentCache.Add(new GUIContent("创建Location"));
            if (root.m_ShowModel)
            {
                m_ContentCache.Add(new GUIContent("隐藏模型"));
            }
            else
            {
                m_ContentCache.Add(new GUIContent("显示模型"));
            }
            Vector2    mousePosition = Event.current.mousePosition;
            GameObject userData      = Selection.activeGameObject;
            int        selected      = -1;

            EditorUtility.DisplayCustomMenu(new Rect(mousePosition.x, mousePosition.y, 0, 0), m_ContentCache.ToArray(), selected,
                                            delegate(object data, string[] opt, int select)
            {
                switch (select)
                {
                case 0:                                //创建Location
                    root.CreateLocation();
                    break;

                case 1:
                    root.m_ShowModel = !root.m_ShowModel;
                    break;
                }
            }, userData);
            Event.current.Use();
        }
示例#3
0
        /// <summary>
        /// 创建根节点
        /// </summary>
        private void CreateRoots(EditorArea area)
        {
            if (m_TreasureRoot == null || m_TreasureRoot.gameObject == null)
            {
                CreateTreasureRoot();
            }
            else
            {
                m_TreasureRoot.Clear(false);
            }
            m_TreasureRoot.Init(area.treasureList);

            if (m_MineralRoot == null || m_MineralRoot.gameObject == null)
            {
                CreateMineralRoot();
            }
            else
            {
                m_MineralRoot.Clear(false);
            }
            m_MineralRoot.Init(area.mineralList);

            //创建CreatureRoot
            if (m_CreatureRoot == null || m_CreatureRoot.gameObject == null)
            {
                GameObject creatureRootObj = new GameObject("CreatureRoot");
                creatureRootObj.transform.SetParent(transform);
                creatureRootObj.transform.localPosition = Vector3.zero;
                creatureRootObj.transform.localRotation = Quaternion.identity;
                m_CreatureRoot = creatureRootObj.AddComponent <CreatureRoot>();
            }
            else
            {
                m_CreatureRoot.Clear(false);
            }
            m_CreatureRoot.Init(area.creatureList, area.teleportList);

            //创建TeleportRoot
            if (m_TeleportRoot == null || m_TeleportRoot.gameObject == null)
            {
                GameObject teleportRootObj = new GameObject("TeleportRoot");
                teleportRootObj.transform.SetParent(transform);
                teleportRootObj.transform.localPosition = Vector3.zero;
                teleportRootObj.transform.localRotation = Quaternion.identity;
                m_TeleportRoot = teleportRootObj.AddComponent <TeleportRoot>();
            }
            else
            {
                m_TeleportRoot.Clear(false);
            }

            m_TeleportRoot.Init(area.teleportList, this);

            //创建LocationRoot
            if (m_LocationRoot == null || m_LocationRoot.gameObject == null)
            {
                GameObject locationRootObj = new GameObject("LocationRoot");
                locationRootObj.transform.SetParent(transform);
                locationRootObj.transform.localPosition = Vector3.zero;
                locationRootObj.transform.localRotation = Quaternion.identity;
                m_LocationRoot = locationRootObj.AddComponent <LocationRoot>();
            }
            else
            {
                m_LocationRoot.Clear(false);
            }
            m_LocationRoot.Init(area.locationList);

            //创建LeapRoot
            if (m_LeapRoot == null || m_LeapRoot.gameObject == null)
            {
                CreateLeapRoot();
            }
            else
            {
                m_LeapRoot.Clear(false);
            }
            m_LeapRoot.Init(area.leapList);

            if (m_TriggerRoot == null || m_TriggerRoot.gameObject == null)
            {
                CreateTriggerRoot();
            }
            else
            {
                m_TriggerRoot.Clear(false);
            }
            m_TriggerRoot.Init(area.triggerList);
        }
示例#4
0
        /// <summary>
        /// 右键响应
        /// </summary>
        /// <param name="instanceID"></param>
        /// <param name="selectionRect"></param>
        private void OnHierarchyGUI(int instanceID, Rect selectionRect)
        {
            if (Event.current != null && selectionRect.Contains(Event.current.mousePosition) &&
                Event.current.button == 1 && Event.current.type <= EventType.MouseUp)
            {
                GameObject selectedGameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
                if (selectedGameObject)
                {
                    CreatureRoot creatureRoot = selectedGameObject.GetComponent <CreatureRoot>();
                    if (creatureRoot != null)
                    {
                        RefreshCreatureRootUI(creatureRoot);
                    }

                    Creature creature = selectedGameObject.GetComponent <Creature>();
                    if (creature != null)
                    {
                        RefreshCreatureUI(creature);
                    }

                    LocationRoot locationRoot = selectedGameObject.GetComponent <LocationRoot>();
                    if (locationRoot != null)
                    {
                        RefreashLocationRootUI(locationRoot);
                    }

                    Location location = selectedGameObject.GetComponent <Location>();
                    if (location != null)
                    {
                        RefreshLocationUI(location);
                    }

                    TriggerRoot triggerRoot = selectedGameObject.GetComponent <TriggerRoot>();
                    if (triggerRoot != null)
                    {
                        RefreshTriggerRootUI(triggerRoot);
                    }
                    Trigger trigger = selectedGameObject.GetComponent <Trigger>();
                    if (trigger != null)
                    {
                        RefreshTriggerUI(trigger);
                    }

                    TeleportRoot teleportRoot = selectedGameObject.GetComponent <TeleportRoot>();
                    if (teleportRoot != null)
                    {
                        RefreashTeleportRootUI(teleportRoot);
                    }

                    GamingMapArea mapArea = selectedGameObject.GetComponent <GamingMapArea>();
                    if (mapArea != null)
                    {
                        RefreshMapAreaUI(mapArea);
                    }

                    GamingMap map = selectedGameObject.GetComponent <GamingMap>();
                    if (map != null)
                    {
                        RefreshMapUI(map);
                    }

                    Leap leap = selectedGameObject.GetComponent <Leap>();
                    if (leap != null)
                    {
                        RefreshLeapUI(leap);
                    }
                }
            }
        }
示例#5
0
 private void OnEnable()
 {
     m_Target = target as LocationRoot;
 }