Exemplo n.º 1
0
    public void Initialize(LIST_TYPE _eListType)
    {
        List <MasterCampShopParam> disp_list = new List <MasterCampShopParam>();

        if (_eListType == LIST_TYPE.SHOP_LIST)
        {
            foreach (MasterCampShopParam param in DMCamp.Instance.masterCampShop.list)
            {
                if (null == DMCamp.Instance.dataCampItem.list.Find(p => p.campitem_id == param.campitem_id))
                {
                    disp_list.Add(param);
                }
            }
        }
        else
        {
            foreach (MasterCampShopParam param in DMCamp.Instance.masterCampShop.list)
            {
                if (null != DMCamp.Instance.dataCampItem.list.Find(p => p.campitem_id == param.campitem_id))
                {
                    disp_list.Add(param);
                }
            }
        }

        m_prefBanner.SetActive(false);
        banner_list.Clear();
        BannerCampShop[] arr = m_goContentRoot.GetComponentsInChildren <BannerCampShop>();
        foreach (BannerCampShop c in arr)
        {
            if (m_prefBanner != c.gameObject)
            {
                GameObject.Destroy(c.gameObject);
            }
        }
        foreach (MasterCampShopParam param in disp_list)
        {
            BannerCampShop script = PrefabManager.Instance.MakeScript <BannerCampShop>(m_prefBanner, m_goContentRoot);

            script.Initialize(param, DMCamp.Instance.masterCampItem.list.Find(p => p.campitem_id == param.campitem_id));
            script.OnClickBanner.AddListener((BannerCampShop _script) =>
            {
                OnClickBanner.Invoke(_script);
            });
            banner_list.Add(script);
        }
    }
Exemplo n.º 2
0
    public static void ShowList(LIST_TYPE newType)
    {
        listType = newType;
        Instance.objEditPanel.SetActive(true);

        int nCount = 0;

        switch (listType)
        {
        case LIST_TYPE.audio_Inner:
            nCount = audio.lisVideoRes.Count;
            foreach (string mediaName in audio.lisVideoRes)
            {
                Button button = EditorPanel.AddItem(mediaName);
                button.onClick.AddListener(() =>
                {
                    EventMgr.startEvent("显示关闭按钮");

                    GameObject objLayer = UIMgr.CreateLayer(10);
                    if (objLayer != null)
                    {
                        EditorPanel.Instance.gameObject.SetActive(false);

                        AudioClip clipMp3 = Resources.Load <AudioClip>("Media/" + mediaName);

                        Music music = MusicMgr.PlayMp3(clipMp3);
                        music.gameObject.AddComponent <_Astroid>();
                    }
                });
            }

            break;

        case LIST_TYPE.audio_Url:
            nCount = audio.lisVideoUrl.Count;
            foreach (string mediaName in audio.lisVideoUrl)
            {
                Button button = EditorPanel.AddItem(mediaName);
                button.onClick.AddListener(() =>
                {
                    EventMgr.startEvent("显示关闭按钮");

                    GameObject objLayer = UIMgr.CreateLayer(10);
                    if (objLayer != null)
                    {
                        EditorPanel.Instance.gameObject.SetActive(false);
                        VideoFile theVideo = VideoMgr.CreateVideoPanel("movie", objLayer);

                        theVideo.playUrl(mediaName);
                    }
                });
            }
            break;

        case LIST_TYPE.audio_Streaming:
            nCount = audio.lisVideoStreaming.Count;
            foreach (string mediaName in audio.lisVideoStreaming)
            {
                Button button = EditorPanel.AddItem(mediaName);
                button.onClick.AddListener(() =>
                {
                    EventMgr.startEvent("显示关闭按钮");

                    GameObject objLayer = UIMgr.CreateLayer(10);
                    if (objLayer != null)
                    {
                        EditorPanel.Instance.gameObject.SetActive(false);
                        Instance.StartCoroutine(Instance.LoadMusic(mediaName));
                        //  VideoFile theVideo = VideoMgr.CreateVideoPanel("movie", objLayer);

                        //  theVideo.playUrl(mediaName);
                    }
                });
            }
            break;

        case LIST_TYPE.video_Inner:
            nCount = video.lisVideoRes.Count;
            foreach (string mediaName in video.lisVideoRes)
            {
                Button button = EditorPanel.AddItem(mediaName);
                button.onClick.AddListener(() =>
                {
                    EventMgr.startEvent("显示关闭按钮");

                    GameObject objLayer = UIMgr.CreateLayer(10);
                    if (objLayer != null)
                    {
                        EditorPanel.Instance.gameObject.SetActive(false);
                        VideoFile theVideo = VideoMgr.CreateVideoPanel("movie", objLayer);

                        VideoClip videoClip = Resources.Load <VideoClip>("Media/" + mediaName);
                        theVideo.Play(videoClip);
                    }
                });
            }

            break;

        case LIST_TYPE.video_Url:
            nCount = video.lisVideoUrl.Count;
            foreach (string mediaName in video.lisVideoUrl)
            {
                Button button = EditorPanel.AddItem(mediaName);
                button.onClick.AddListener(() =>
                {
                    EventMgr.startEvent("显示关闭按钮");

                    GameObject objLayer = UIMgr.CreateLayer(10);
                    if (objLayer != null)
                    {
                        EditorPanel.Instance.gameObject.SetActive(false);
                        VideoFile theVideo = VideoMgr.CreateVideoPanel("movie", objLayer);

                        theVideo.playUrl(mediaName);
                    }
                });
            }
            break;

        case LIST_TYPE.video_Streaming:
            nCount = video.lisVideoStreaming.Count;
            foreach (string mediaName in video.lisVideoStreaming)
            {
                Button button = EditorPanel.AddItem(mediaName);
                button.onClick.AddListener(() =>
                {
                    EventMgr.startEvent("显示关闭按钮");

                    GameObject objLayer = UIMgr.CreateLayer(10);
                    if (objLayer != null)
                    {
                        EditorPanel.Instance.gameObject.SetActive(false);
                        VideoFile theVideo = VideoMgr.CreateVideoPanel("movie", objLayer);

                        theVideo.playUrl(mediaName);
                    }
                });
            }
            break;

        case LIST_TYPE.List_None:
            break;
        }
        Vector2 sz = EditorPanel.Instance.parent.GetComponent <RectTransform>().sizeDelta;

        sz.y += 20;
        sz.y  = nCount * 64;
        EditorPanel.Instance.parent.GetComponent <RectTransform>().sizeDelta = sz;
    }
        // GUI
        //--------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _funcResult == null)
            {
                return;
            }

            Color prevColor = GUI.backgroundColor;

            GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f);

            //Top : (탭) 또는 없음

            int height_Top    = (_requestTarget == REQUEST_TARGET.MeshAndMeshGroups) ? 25 : 0;
            int yOffset       = (_requestTarget == REQUEST_TARGET.MeshAndMeshGroups) ? (height_Top + 11) : (height_Top + 10);
            int height_Bottom = 70;
            int height_Main   = height - (height_Top + height_Bottom + 20);


            GUI.Box(new Rect(0, yOffset, width, height_Main), "");


            GUI.backgroundColor = prevColor;

            EditorGUILayout.BeginVertical();


            //Request Type이 "Mesh" 또는 "ChildTransform"이라면 탭이 없다.
            //Request Type이 "MeshAndMeshGroups"라면 탭이 있다.


            //1. Tab
            GUILayout.Space(5);


            int    width_BtnHalf = (width - 10) / 2 - 2;
            string strCategory   = "";

            if (_requestTarget == REQUEST_TARGET.MeshAndMeshGroups)
            {
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(height_Top));

                GUILayout.Space(5);

                //1. Mesh + MeshGroup을 선택하는 경우 탭으로 구분한다.
                if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Mesh), (_target == TARGET_TAB.Mesh), width_BtnHalf, height_Top))                //"Mesh"
                {
                    _target     = TARGET_TAB.Mesh;
                    _scrollList = Vector2.zero;
                }

                if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_MeshGroup), (_target == TARGET_TAB.MeshGroup), width_BtnHalf, height_Top))                //"MeshGroup"
                {
                    _target     = TARGET_TAB.MeshGroup;
                    _scrollList = Vector2.zero;
                }


                if (_target == TARGET_TAB.Mesh)
                {
                    //"Meshes";
                    strCategory = _editor.GetText(TEXT.DLG_Meshes);
                }
                else
                {
                    //"Mesh Groups";
                    strCategory = _editor.GetText(TEXT.DLG_MeshGroups);
                }

                EditorGUILayout.EndHorizontal();
            }
            else
            {
                if (_requestTarget == REQUEST_TARGET.Mesh)
                {
                    //"Meshes";
                    strCategory = _editor.GetText(TEXT.DLG_Meshes);
                }
                else
                {
                    //Child MeshTransform > MeshGroup 이름;
                    strCategory = _meshGroup._name;
                }

                GUILayout.Space(5);
            }


            LIST_TYPE curListType = LIST_TYPE.Mesh;

            switch (_requestTarget)
            {
            case REQUEST_TARGET.Mesh:
                curListType = LIST_TYPE.Mesh;
                break;

            case REQUEST_TARGET.ChildMeshTransforms:
                curListType = LIST_TYPE.MeshTransforms;
                break;

            case REQUEST_TARGET.MeshAndMeshGroups:
            {
                if (_target == TARGET_TAB.Mesh)
                {
                    curListType = LIST_TYPE.Mesh;
                }
                else
                {
                    curListType = LIST_TYPE.MeshGroup;
                }
            }
            break;
            }


            GUIStyle guiStyle_None     = new GUIStyle(GUIStyle.none);
            GUIStyle guiStyle_Selected = new GUIStyle(GUIStyle.none);

            if (EditorGUIUtility.isProSkin)
            {
                guiStyle_Selected.normal.textColor = Color.cyan;
                guiStyle_None.normal.textColor     = GUI.skin.label.normal.textColor;
            }
            else
            {
                guiStyle_Selected.normal.textColor = Color.white;
                guiStyle_None.normal.textColor     = Color.black;
            }

            Texture2D whildImg = apEditorUtil.WhiteTexture;


            int height_ListItem = 25;

            //string strSelected = _editor.GetText(TEXT.DLG_Selected);
            //string strNotSelected = _editor.GetText(TEXT.DLG_NotSelected);

            _scrollList = EditorGUILayout.BeginScrollView(_scrollList, GUILayout.Width(width), GUILayout.Height(height_Main));
            EditorGUILayout.BeginVertical();

            GUILayout.Button(new GUIContent(strCategory, _img_FoldDown), guiStyle_None, GUILayout.Height(height_ListItem));            //<투명 버튼

            //리스트 방식 : 아이콘 + 이름 / Selected 버튼 (토글)

            //int width_SelectBtn = 100;
            //int width_Label = width - (width_SelectBtn + 42);

            bool isSelected = false;

            GUIStyle guiStyle_ItemLabelBtn = new GUIStyle(GUI.skin.label);

            guiStyle_ItemLabelBtn.alignment = TextAnchor.MiddleLeft;

            //Ctrl키나 Shift키를 누르면 여러개를 선택할 수 있다.
            bool isCtrlOrShift = false;

            if (Event.current.shift
#if UNITY_EDITOR_OSX
                || Event.current.command
#else
                || Event.current.control
#endif
                )
            {
                isCtrlOrShift = true;
            }


            //어떤 리스트를 보여야 하는지 여부
            if (curListType == LIST_TYPE.Mesh)
            {
                //1. Mesh를 출력하자
                apMesh curMesh = null;
                for (int i = 0; i < _meshes.Count; i++)
                {
                    curMesh = _meshes[i];

                    isSelected = _selectedObjects.Contains(curMesh);


                    if (DrawItem(curMesh._name, _img_Mesh, isSelected, guiStyle_None, guiStyle_Selected, i, width, height_ListItem, _scrollList.x))
                    {
                        if (!isCtrlOrShift)
                        {
                            //일단 무조건 클리어
                            _selectedObjects.Clear();
                        }

                        if (isSelected)
                        {
                            _selectedObjects.Remove(curMesh);
                        }
                        else
                        {
                            _selectedObjects.Add(curMesh);
                        }
                    }
                    GUILayout.Space(2);
                }
            }
            else if (curListType == LIST_TYPE.MeshGroup)
            {
                //2. MeshGroup을 출력하자
                apMeshGroup curMeshGroup = null;
                for (int i = 0; i < _meshGroups.Count; i++)
                {
                    curMeshGroup = _meshGroups[i];

                    isSelected = _selectedObjects.Contains(curMeshGroup);


                    if (DrawItem(curMeshGroup._name, _img_MeshGroup, isSelected, guiStyle_None, guiStyle_Selected, i, width, height_ListItem, _scrollList.x))
                    {
                        if (!isCtrlOrShift)
                        {
                            //일단 무조건 클리어
                            _selectedObjects.Clear();
                        }

                        if (isSelected)
                        {
                            _selectedObjects.Remove(curMeshGroup);
                        }
                        else
                        {
                            _selectedObjects.Add(curMeshGroup);
                        }
                    }
                    GUILayout.Space(2);
                }
            }
            else
            {
                //3. MeshTransform을 출력하자
                apTransform_Mesh curMeshTF = null;
                for (int i = 0; i < _meshTransforms.Count; i++)
                {
                    curMeshTF = _meshTransforms[i];

                    isSelected = _selectedObjects.Contains(curMeshTF);


                    if (DrawItem(curMeshTF._nickName, _img_Mesh, isSelected, guiStyle_None, guiStyle_Selected, i, width, height_ListItem, _scrollList.x))
                    {
                        if (!isCtrlOrShift)
                        {
                            //일단 무조건 클리어
                            _selectedObjects.Clear();
                        }

                        if (isSelected)
                        {
                            _selectedObjects.Remove(curMeshTF);
                        }
                        else
                        {
                            _selectedObjects.Add(curMeshTF);
                        }
                    }
                    GUILayout.Space(2);
                }
            }

            GUILayout.Space(height + 20);

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndVertical();

            GUILayout.Space(10);

            //첫줄에는 Select All / Deselect All
            //둘째줄에는 Add 또는 Apply (인자로 받음) / Close
            EditorGUILayout.BeginHorizontal(GUILayout.Height(22));
            GUILayout.Space(5);
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_SelectAll), GUILayout.Width(width_BtnHalf), GUILayout.Height(22)))
            {
                //Select All
                for (int i = 0; i < _meshes.Count; i++)
                {
                    apMesh curMesh = _meshes[i];
                    if (!_selectedObjects.Contains(curMesh))
                    {
                        _selectedObjects.Add(curMesh);
                    }
                }

                for (int i = 0; i < _meshGroups.Count; i++)
                {
                    apMeshGroup curMeshGroup = _meshGroups[i];
                    if (!_selectedObjects.Contains(curMeshGroup))
                    {
                        _selectedObjects.Add(curMeshGroup);
                    }
                }

                for (int i = 0; i < _meshTransforms.Count; i++)
                {
                    apTransform_Mesh curMeshTF = _meshTransforms[i];
                    if (!_selectedObjects.Contains(curMeshTF))
                    {
                        _selectedObjects.Add(curMeshTF);
                    }
                }
            }
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_DeselectAll), GUILayout.Width(width_BtnHalf), GUILayout.Height(22)))
            {
                //Deselect All
                _selectedObjects.Clear();
            }


            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            EditorGUILayout.BeginHorizontal(GUILayout.Height(30));
            GUILayout.Space(5);

            bool isClose = false;
            if (GUILayout.Button(_positiveBtnText, GUILayout.Width(width_BtnHalf), GUILayout.Height(30)))
            {
                _funcResult(true, _loadKey, _selectedObjects, _savedObject);
                isClose = true;
            }
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_Close), GUILayout.Width(width_BtnHalf), GUILayout.Height(30)))            //"Close"
            {
                _funcResult(false, _loadKey, null, _savedObject);
                isClose = true;
            }
            EditorGUILayout.EndHorizontal();

            if (isClose)
            {
                CloseDialog();
            }
        }