Ejemplo n.º 1
0
        public void LoadListView(LoadType type = LoadType.MapObject)
        {
            img_selected.transform.SetParent(transform, true);

            img_selected.transform.position = Vector3.one * 100000f;
            foreach (var p in _child)
            {
                GameObject.Destroy(p.gameObject);
            }
            _child.Clear();

            if (type == LoadType.Weapon)
            {
                var list = MapEditorConfig.GetWeapons();
                foreach (var id in list)
                {
                    var obj =
                        MapLoader.ins.LoadEditorV1("OneMapObjectWeapon");

                    //PrefabsMgr.Load("Map/Prefabs/Editor/OneMapObjectWeapon");
                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    //   Debug.LogError("load id111111111111111111111111111111111111 = " + id);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectWeapon>().InitData(id);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }
                    _child.Add(obj);
                }
            }
            else if (type == LoadType.MapObject)
            {
                var list = MapEditorConfig.GetMapObject(MapEditorConfig.CurrentSelectTheme);
                //加载物件
                foreach (var p in list)
                {
                    var obj = MapLoader.ins.LoadEditorV1("OneMapObject");

                    //PrefabsMgr.Load("Map/Prefabs/Editor/OneMapObject");
                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectBase>().InitData(p);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }
                    _child.Add(obj);
                }
            }

            this.ResizeContent(_child.Count);
        }
Ejemplo n.º 2
0
        public void LoadListView(int group_id = 1, LoadType type = LoadType.MapObject)
        {
            _group_id = group_id;

            if (img_selected != null)
            {
                img_selected.transform.SetParent(transform, true);
                img_selected.transform.position = Vector3.one * 100000f;
            }

            foreach (var p in _child)
            {
                GameObject.Destroy(p.gameObject);
            }
            _child.Clear();

            if (type == LoadType.Weapon)
            {
                var list = MapEditorConfig.GetWeapons();
                foreach (var id in list)
                {
                    var obj = MapLoader.ins.LoadEditorV1("OneMapObjectWeapon");

                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectWeapon>().InitData(id);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }
                    _child.Add(obj);
                }
            }
            else if (type == LoadType.MapObject)
            {
                var list = GameConfig.instance.GetComponentsByGroup(group_id);
                foreach (var value in list)
                {
                    var obj = MapLoader.ins.LoadEditorV1("OneMapObject");

                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectBase>().InitData(value.id);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }

                    //切换分组重新设置之前已经选中的组件
                    if ((value.id == MapEditorInputMgr.ins.currentSelectId) &&
                        (MapEditorInputMgr.ins.currentSelectId > 0))
                    {
                        if (img_selected != null)
                        {
                            img_selected.transform.SetParent(obj.transform, true);
                            img_selected.transform.localPosition = Vector3.zero;
                        }
                    }
                    _child.Add(obj);
                }


                //重新加载正常组件,进入正常组件编辑模式
                if (list.Length > 0)
                {
                    MapEditorUIMgr.ins.GetPanel <UIPanelMapEditor>().ChangeToEditObjectMode();
                }
            }
            else if (type == LoadType.SpawPoint)
            {
                var list = GameConfig.instance.GetComponentsByGroup(group_id);
                foreach (var value in list)
                {
                    var obj = MapLoader.ins.LoadEditorV1("OneMapObject");

                    if (obj == null)
                    {
                        break;
                    }
                    obj = GameObject.Instantiate <GameObject>(obj);
                    obj.transform.SetParent(_obj_content.transform, false);
                    bool ok = obj.GetComponentFully <OneMapObjectBase>().InitData(value.id);
                    if (!ok)
                    {
                        GameObject.DestroyImmediate(obj);
                        break;
                    }
                    //切换分组重新设置之前已经选中的组件
                    if ((value.id == MapEditorInputMgr.ins.currentSelectId) &&
                        (MapEditorInputMgr.ins.currentSelectId > 0))
                    {
                        if (img_selected != null)
                        {
                            img_selected.transform.SetParent(obj.transform, true);
                            img_selected.transform.localPosition = Vector3.zero;
                        }
                    }
                    _child.Add(obj);
                }
            }

            this.ResizeContent(_child.Count);

            if (_child.Count > 0)
            {
                this.Text_none.gameObject.SetActive(false);
            }
            else
            {
                this.Text_none.gameObject.SetActive(true);
            }
        }