Exemplo n.º 1
0
        // Bake
        //----------------------------------------------------------
        //Render Buffer는 Bake가 3단계로 이루어진다.
        //데이터가 절차적으로 생성되는 바람에.. 어쩔 수 없이... 힁
        public void Bake_Init(apPortrait portrait, apOptRootUnit rootUnit, apRootUnit srcRootUnit)
        {
            Clear();

            _bakedBuffers.Clear();
            _ZPerDepth = portrait._bakeZSize;
        }
Exemplo n.º 2
0
 //추가 12.6
 //Sorted Render Buffer에 대한 Bake
 public void BakeSortedRenderBuffer(apPortrait portrait, apRootUnit srcRootUnit)
 {
     if (_sortedRenderBuffer == null)
     {
         _sortedRenderBuffer = new apOptSortedRenderBuffer();
     }
     _sortedRenderBuffer.Bake_Init(portrait, this, srcRootUnit);
 }
Exemplo n.º 3
0
        // Bake
        //----------------------------------------------------------
        //Render Buffer는 Bake가 3단계로 이루어진다.
        //데이터가 절차적으로 생성되는 바람에.. 어쩔 수 없이... 힁
        public void Bake_Init(apPortrait portrait, apOptRootUnit rootUnit, apRootUnit srcRootUnit)
        {
            Clear();

            _bakedBuffers.Clear();
            _ZPerDepth = portrait._bakeZSize;

            _sortingOrderOption = portrait._sortingOrderOption;            //추가 19.8.19
            SetSortingOrderChangedAutomatically(true);
        }
        // 제어 함수
        /// <summary>
        /// [Please do not use it] Set Root Unit in Editor
        /// </summary>
        /// <param name="rootUnit"></param>
        public void SetRootUnit_Editor(apRootUnit rootUnit)
        {
            bool isChanged = (_curRootUnitInEditor != rootUnit);

            _curRootUnitInEditor = rootUnit;

            if (isChanged)
            {
                _curAnimClipInEditor = null;
            }
        }
Exemplo n.º 5
0
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                Debug.LogError("Exit - Editor / Portrait is Null");
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자 + Overall Menu가 아니라면..
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait || _editor.Select.SelectionType != apSelection.SELECTION_TYPE.Overall)
            {
                Debug.LogError("Exit - Editor / Portrait Missmatch");
                CloseDialog();
                return;
            }

            //여기서 체크 및 실행하자
            //Request => Process => Process 처리
            if (_exportProcessType == EXPORT_TYPE.None && _exportRequestType != EXPORT_TYPE.None)
            {
                _iProcess = 0;
                switch (_exportRequestType)
                {
                case EXPORT_TYPE.None:
                    break;

                case EXPORT_TYPE.Thumbnail:
                    _exportProcessType = EXPORT_TYPE.Thumbnail;
                    break;

                case EXPORT_TYPE.PNG:
                    _exportProcessType = EXPORT_TYPE.PNG;
                    break;

                case EXPORT_TYPE.GIFAnimation:
                    _exportProcessType = EXPORT_TYPE.GIFAnimation;
                    break;
                }

                _exportRequestType = EXPORT_TYPE.None;
            }
            switch (_exportProcessType)
            {
            case EXPORT_TYPE.None:
                break;

            case EXPORT_TYPE.Thumbnail:
                Process_MakeThumbnail();
                break;

            case EXPORT_TYPE.PNG:
                Process_PNGScreenShot();
                break;

            case EXPORT_TYPE.GIFAnimation:
                Process_MakeGIF();
                break;
            }

            _scroll = EditorGUILayout.BeginScrollView(_scroll, false, true, GUILayout.Width(width), GUILayout.Height(height));
            width  -= 24;
            EditorGUILayout.BeginVertical(GUILayout.Width(width));

            int settingWidth       = ((width - 10) / 3) - 4;
            int settingWidth_Label = 50;
            int settingWidth_Value = settingWidth - (50 + 8);
            int settingHeight      = 70;

            EditorGUILayout.LabelField("Setting");
            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(settingHeight));
            GUILayout.Space(5);

            //Position
            //------------------------
            EditorGUILayout.BeginVertical(GUILayout.Width(settingWidth), GUILayout.Height(settingHeight));


            EditorGUILayout.LabelField("Position", GUILayout.Width(settingWidth));
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("X", GUILayout.Width(settingWidth_Label));
            int posX = EditorGUILayout.DelayedIntField(_editor._captureFrame_PosX, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Y", GUILayout.Width(settingWidth_Label));
            int posY = EditorGUILayout.DelayedIntField(_editor._captureFrame_PosY, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
            //------------------------


            //Capture Size
            //------------------------
            EditorGUILayout.BeginVertical(GUILayout.Width(settingWidth), GUILayout.Height(settingHeight));

            EditorGUILayout.LabelField("Capture Size", GUILayout.Width(settingWidth));
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Width", GUILayout.Width(settingWidth_Label));
            int srcSizeWidth = EditorGUILayout.DelayedIntField(_editor._captureFrame_SrcWidth, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Height", GUILayout.Width(settingWidth_Label));
            int srcSizeHeight = EditorGUILayout.DelayedIntField(_editor._captureFrame_SrcHeight, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();


            if (srcSizeWidth < 8)
            {
                srcSizeWidth = 8;
            }
            if (srcSizeHeight < 8)
            {
                srcSizeHeight = 8;
            }

            EditorGUILayout.EndVertical();


            //------------------------

            //File Size
            //-------------------------------
            EditorGUILayout.BeginVertical(GUILayout.Width(settingWidth), GUILayout.Height(settingHeight));

            EditorGUILayout.LabelField("File Size", GUILayout.Width(settingWidth));

            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Width", GUILayout.Width(settingWidth_Label));
            int dstSizeWidth = EditorGUILayout.DelayedIntField(_editor._captureFrame_DstWidth, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Height", GUILayout.Width(settingWidth_Label));
            int dstSizeHeight = EditorGUILayout.DelayedIntField(_editor._captureFrame_DstHeight, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();

            if (dstSizeWidth < 8)
            {
                dstSizeWidth = 8;
            }
            if (dstSizeHeight < 8)
            {
                dstSizeHeight = 8;
            }



            EditorGUILayout.EndVertical();
            //-------------------------------

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(30));
            GUILayout.Space(5);
            int setting2CompWidth = ((width - 10) / 2) - 8;

            //Color와 AspectRatio
            EditorGUILayout.LabelField("BG Color", GUILayout.Width(80));
            Color prevCaptureColor = _editor._captureFrame_Color;

            try
            {
                _editor._captureFrame_Color = EditorGUILayout.ColorField(_editor._captureFrame_Color, GUILayout.Width(setting2CompWidth - 86));
            }
            catch (Exception) { }


            GUILayout.Space(30);
            if (apEditorUtil.ToggledButton_2Side("Aspect Ratio Fixed", "Aspect Ratio Not Fixed", _editor._isCaptureAspectRatioFixed, true, setting2CompWidth - 20, 20))
            {
                _editor._isCaptureAspectRatioFixed = !_editor._isCaptureAspectRatioFixed;

                if (_editor._isCaptureAspectRatioFixed)
                {
                    //AspectRatio를 굳혔다.
                    //Dst계열 변수를 Src에 맞춘다.
                    //Height를 고정, Width를 맞춘다.
                    _editor._captureFrame_DstWidth = GetAspectRatio_Width(_editor._captureFrame_DstHeight, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                    dstSizeWidth = _editor._captureFrame_DstWidth;
                }

                _editor.SaveEditorPref();


                apEditorUtil.ReleaseGUIFocus();
            }
            EditorGUILayout.EndHorizontal();


            //AspectRatio를 맞추어보자
            if (_editor._isCaptureAspectRatioFixed)
            {
                if (srcSizeWidth != _editor._captureFrame_SrcWidth)
                {
                    //Width가 바뀌었다. => Height를 맞추자
                    srcSizeHeight = GetAspectRatio_Height(srcSizeWidth, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                    //>> Dst도 바꾸자 => Width
                    dstSizeWidth = GetAspectRatio_Width(dstSizeHeight, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                }
                else if (srcSizeHeight != _editor._captureFrame_SrcHeight)
                {
                    //Height가 바뀌었다. => Width를 맞추자
                    srcSizeWidth = GetAspectRatio_Width(srcSizeHeight, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                    //>> Dst도 바꾸자 => Height
                    dstSizeHeight = GetAspectRatio_Height(dstSizeWidth, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                }
                else if (dstSizeWidth != _editor._captureFrame_DstWidth)
                {
                    //Width가 바뀌었다. => Height를 맞추자
                    dstSizeHeight = GetAspectRatio_Height(dstSizeWidth, _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight);
                    //>> Src도 바꾸다 => Width
                    srcSizeWidth = GetAspectRatio_Width(srcSizeHeight, _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight);
                }
                else if (dstSizeHeight != _editor._captureFrame_DstHeight)
                {
                    //Height가 바뀌었다. => Width를 맞추자
                    dstSizeWidth = GetAspectRatio_Width(dstSizeHeight, _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight);
                    //>> Dst도 바꾸자 => Height
                    srcSizeHeight = GetAspectRatio_Height(srcSizeWidth, _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight);
                }
            }

            if (posX != _editor._captureFrame_PosX ||
                posY != _editor._captureFrame_PosY ||
                srcSizeWidth != _editor._captureFrame_SrcWidth ||
                srcSizeHeight != _editor._captureFrame_SrcHeight ||
                dstSizeWidth != _editor._captureFrame_DstWidth ||
                dstSizeHeight != _editor._captureFrame_DstHeight
                )
            {
                _editor._captureFrame_PosX      = posX;
                _editor._captureFrame_PosY      = posY;
                _editor._captureFrame_SrcWidth  = srcSizeWidth;
                _editor._captureFrame_SrcHeight = srcSizeHeight;
                _editor._captureFrame_DstWidth  = dstSizeWidth;
                _editor._captureFrame_DstHeight = dstSizeHeight;

                _editor.SaveEditorPref();
                apEditorUtil.ReleaseGUIFocus();
            }

            if (prevCaptureColor.r != _editor._captureFrame_Color.r ||
                prevCaptureColor.g != _editor._captureFrame_Color.g ||
                prevCaptureColor.b != _editor._captureFrame_Color.b)
            {
                _editor.SaveEditorPref();
                //색상은 GUIFocus를 null로 만들면 안되기에..
            }



            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);

            EditorGUILayout.LabelField("Thumbnail Capture");
            GUILayout.Space(5);

            EditorGUILayout.LabelField("File Path");
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
            GUILayout.Space(5);
            GUILayout.Box(_editor._portrait._thumbnailImage, GUI.skin.label, GUILayout.Width(50), GUILayout.Height(25));
            _editor._portrait._imageFilePath_Thumbnail = EditorGUILayout.TextField(_editor._portrait._imageFilePath_Thumbnail, GUILayout.Width(width - (130)));
            if (GUILayout.Button("Change", GUILayout.Width(60)))
            {
                string fileName = EditorUtility.SaveFilePanelInProject("Thumbnail File Path", _editor._portrait.name + "_Thumb.png", "png", "Please Enter a file name to save Thumbnail to");
                if (!string.IsNullOrEmpty(fileName))
                {
                    _editor._portrait._imageFilePath_Thumbnail = fileName;
                    apEditorUtil.ReleaseGUIFocus();
                }
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Make Thumbnail", GUILayout.Width(width), GUILayout.Height(30)))
            {
                if (string.IsNullOrEmpty(_editor._portrait._imageFilePath_Thumbnail))
                {
                    //EditorUtility.DisplayDialog("Thumbnail Creating Failed", "File Name is Empty", "Close");
                    EditorUtility.DisplayDialog(_editor.GetText(apLocalization.TEXT.ThumbCreateFailed_Title),
                                                _editor.GetText(apLocalization.TEXT.ThumbCreateFailed_Body_NoFile),
                                                _editor.GetText(apLocalization.TEXT.Close)
                                                );
                }
                else
                {
                    RequestExport(EXPORT_TYPE.Thumbnail);
                    #region [비동기 스타일로 변경]
                    //int thumbnailWidth = 256;
                    //int thumbnailHeight = 128;

                    //float preferAspectRatio = (float)thumbnailWidth / (float)thumbnailHeight;

                    //float srcAspectRatio = (float)_editor._captureFrame_SrcWidth / (float)_editor._captureFrame_SrcHeight;
                    ////긴쪽으로 캡쳐 크기를 맞춘다.
                    //int srcThumbWidth = _editor._captureFrame_SrcWidth;
                    //int srcThumbHeight = _editor._captureFrame_SrcHeight;
                    ////AspectRatio = W / H
                    //if(srcAspectRatio < preferAspectRatio)
                    //{
                    //	//가로가 더 길군요.
                    //	//가로를 자릅시다.

                    //	//H = W / AspectRatio;
                    //	srcThumbHeight = (int)((srcThumbWidth / preferAspectRatio) + 0.5f);
                    //}
                    //else
                    //{
                    //	//세로가 더 길군요.
                    //	//세로를 자릅시다.
                    //	//W = AspectRatio * H
                    //	srcThumbWidth = (int)((srcThumbHeight * preferAspectRatio) + 0.5f);
                    //}


                    //Texture2D result = _editor.Exporter.RenderToTexture(_editor.Select.RootUnit._childMeshGroup,
                    //												(int)(_editor._captureFrame_PosX + apGL.WindowSizeHalf.x), (int)(_editor._captureFrame_PosY + apGL.WindowSizeHalf.y),
                    //												srcThumbWidth, srcThumbHeight,
                    //												thumbnailWidth, thumbnailHeight,
                    //												_editor._captureFrame_Color
                    //												);

                    //if (result != null)
                    //{
                    //	//이미지를 저장하자
                    //	//이건 Asset으로 자동 저장
                    //	string filePathWOExtension = _editor._portrait._imageFilePath_Thumbnail.Substring(0, _editor._portrait._imageFilePath_Thumbnail.Length - 4);
                    //	bool isSaveSuccess = _editor.Exporter.SaveTexture2DToPNG(result, filePathWOExtension, true);

                    //	if(isSaveSuccess)
                    //	{
                    //		AssetDatabase.Refresh();

                    //		_editor._portrait._thumbnailImage = AssetDatabase.LoadAssetAtPath<Texture2D>(_editor._portrait._imageFilePath_Thumbnail);
                    //	}
                    //}
                    #endregion
                }
            }

            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);

            //Screenshot을 찍자
            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
            EditorGUILayout.LabelField("Screenshot Capture");
            GUILayout.Space(5);
            if (GUILayout.Button("Take a Screenshot", GUILayout.Width(width), GUILayout.Height(30)))
            {
                RequestExport(EXPORT_TYPE.PNG);
            }

            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------

            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);


            //GIF Animation을 만들자
            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
            EditorGUILayout.LabelField("GIF Animation");
            GUILayout.Space(5);

            apRootUnit curRootUnit = _editor.Select.RootUnit;

            if (_curRootUnit != curRootUnit)
            {
                //AnimList 리셋
                _animClips.Clear();

                _curRootUnit = curRootUnit;
                if (_curRootUnit != null)
                {
                    for (int i = 0; i < _editor._portrait._animClips.Count; i++)
                    {
                        apAnimClip animClip = _editor._portrait._animClips[i];
                        if (animClip._targetMeshGroup == _curRootUnit._childMeshGroup)
                        {
                            _animClips.Add(animClip);
                        }
                    }
                }

                _selectedAnimClip = null;
            }
            if (curRootUnit == null)
            {
                _selectedAnimClip = null;
            }
            else
            {
                if (_selectedAnimClip != null && _animClips.Count > 0)
                {
                    if (!_animClips.Contains(_selectedAnimClip))
                    {
                        _selectedAnimClip = null;
                    }
                }
                else
                {
                    _selectedAnimClip = null;
                }
            }

            string animName    = "< Animation is not selected >";
            Color  animBGColor = new Color(1.0f, 0.7f, 0.7f, 1.0f);
            if (_selectedAnimClip != null)
            {
                animName    = _selectedAnimClip._name;
                animBGColor = new Color(0.7f, 1.0f, 0.7f, 1.0f);
            }

            Color    prevGUIColor = GUI.backgroundColor;
            GUIStyle guiStyleBox  = new GUIStyle(GUI.skin.box);
            guiStyleBox.alignment = TextAnchor.MiddleCenter;

            GUI.backgroundColor = animBGColor;

            GUILayout.Box(animName, guiStyleBox, GUILayout.Width(width), GUILayout.Height(30));

            GUI.backgroundColor = prevGUIColor;

            GUILayout.Space(5);
            int width_GIFSetting = (width - 32) / 2;

            int gifQuality = 256 - _editor._captureFrame_GIFSampleQuality;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            string strQuality = "";
            if (gifQuality > 200)
            {
                strQuality = "Quality [ High ]";
            }
            else if (gifQuality > 120)
            {
                strQuality = "Quality [ Medium ]";
            }
            else
            {
                strQuality = "Quality [ Low ]";
            }
            EditorGUILayout.LabelField(strQuality, GUILayout.Width(width_GIFSetting));
            GUILayout.Space(20);

            EditorGUILayout.LabelField("Loop Count", GUILayout.Width(width_GIFSetting));

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            //10 ~ 256
            //246 ~ 0
            gifQuality = EditorGUILayout.IntSlider(gifQuality, 0, 246, GUILayout.Width(width_GIFSetting));

            gifQuality = 256 - gifQuality;
            if (_editor._captureFrame_GIFSampleQuality != gifQuality)
            {
                _editor._captureFrame_GIFSampleQuality = gifQuality;
                _editor.SaveEditorPref();
            }

            GUILayout.Space(20);

            int loopCount = EditorGUILayout.DelayedIntField(_editor._captureFrame_GIFSampleLoopCount, GUILayout.Width(width_GIFSetting));

            if (loopCount != _editor._captureFrame_GIFSampleLoopCount)
            {
                loopCount = Mathf.Clamp(loopCount, 1, 10);
                _editor._captureFrame_GIFSampleLoopCount = loopCount;
                _editor.SaveEditorPref();
            }

            EditorGUILayout.EndHorizontal();

            //GUILayout.Space(10);

            //Rect lastRect_Progress = GUILayoutUtility.GetLastRect();

            //Rect barRect = new Rect(lastRect_Progress.x + 5, lastRect_Progress.y + 10, width - 5, 16);
            //float barRatio = 0.0f;
            //string strProcessName = "";
            //if(_exportProcessType == EXPORT_TYPE.GIFAnimation)
            //{
            //	barRatio = Mathf.Clamp01((float)_exportProcessX100 / 100.0f);
            //	strProcessName = "Exporting.. [ " + _exportProcessX100 + "% ]";
            //}

            ////EditorGUI.ProgressBar(barRect, barRatio, "Convert PSD Data To Editor..");

            //EditorGUI.ProgressBar(barRect, barRatio, strProcessName);
            //GUILayout.Space(20);


            if (apEditorUtil.ToggledButton_2Side("Take a GIF Animation", "Take a GIF Animation", false, (_selectedAnimClip != null), width, 30))
            {
                //RequestExport(EXPORT_TYPE.GIFAnimation);//리퀘스트 안할래..
                string defFileName  = "GIF_" + DateTime.Now.Year + "" + DateTime.Now.Month + "" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second + ".gif";
                string saveFilePath = EditorUtility.SaveFilePanel("Save GIF Animation", _prevFilePath_Directory, defFileName, "gif");
                if (!string.IsNullOrEmpty(saveFilePath))
                {
                    bool result = _editor.Exporter.MakeGIFAnimation(saveFilePath,
                                                                    _editor.Select.RootUnit._childMeshGroup,
                                                                    _selectedAnimClip, _editor._captureFrame_GIFSampleLoopCount,
                                                                    (int)(_editor._captureFrame_PosX + apGL.WindowSizeHalf.x), (int)(_editor._captureFrame_PosY + apGL.WindowSizeHalf.y),
                                                                    _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight,
                                                                    _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight,
                                                                    _editor._captureFrame_Color,
                                                                    _editor._captureFrame_GIFSampleQuality
                                                                    );
                    if (result)
                    {
                        System.IO.FileInfo fi = new System.IO.FileInfo(saveFilePath);

                        Application.OpenURL("file://" + fi.Directory.FullName);
                        Application.OpenURL("file://" + saveFilePath);

                        _prevFilePath           = _editor.Exporter.GIF_FilePath;
                        _prevFilePath_Directory = fi.Directory.FullName;
                    }
                }
            }

            GUILayout.Space(10);

            GUIStyle guiStyle = new GUIStyle(GUIStyle.none);
            guiStyle.normal.textColor = GUI.skin.label.normal.textColor;

            GUILayout.Button("Animation Clips", guiStyle, GUILayout.Width(width), GUILayout.Height(20));            //투명 버튼


            //애니메이션 클립 리스트를 만들어야 한다.
            if (_animClips.Count > 0)
            {
                Texture2D iconImage = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Animation);

                apAnimClip nextSelectedAnimClip = null;
                for (int i = 0; i < _animClips.Count; i++)
                {
                    apAnimClip animClip = _animClips[i];

                    if (animClip == _selectedAnimClip)
                    {
                        Rect lastRect = GUILayoutUtility.GetLastRect();
                        prevCaptureColor = GUI.backgroundColor;

                        GUI.backgroundColor = new Color(0.4f, 0.8f, 1.0f, 1.0f);

                        GUI.Box(new Rect(lastRect.x, lastRect.y + 20, width, 20), "");
                        GUI.backgroundColor = prevGUIColor;
                    }

                    EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50));
                    GUILayout.Space(15);
                    if (GUILayout.Button(new GUIContent(" " + animClip._name, iconImage), guiStyle, GUILayout.Width(width - 35), GUILayout.Height(20)))
                    {
                        nextSelectedAnimClip = animClip;
                    }

                    EditorGUILayout.EndHorizontal();
                }

                if (nextSelectedAnimClip != null)
                {
                    for (int i = 0; i < _editor._portrait._animClips.Count; i++)
                    {
                        _editor._portrait._animClips[i]._isSelectedInEditor = false;
                    }

                    nextSelectedAnimClip.LinkEditor(_editor._portrait);
                    nextSelectedAnimClip.RefreshTimelines();
                    nextSelectedAnimClip.SetFrame_Editor(nextSelectedAnimClip.StartFrame);
                    nextSelectedAnimClip.Pause_Editor();
                    nextSelectedAnimClip._isSelectedInEditor = true;
                    _selectedAnimClip = nextSelectedAnimClip;

                    _editor._portrait._animPlayManager.SetAnimClip_Editor(_selectedAnimClip);
                }
            }

            EditorGUILayout.EndVertical();
            GUILayout.Space(500);

            EditorGUILayout.EndScrollView();


            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
        }
Exemplo n.º 6
0
        // Functions
        //---------------------------------------------
        public void ResetAllUnits()
        {
            _isNeedReset = false;
            _units_All.Clear();
            _units_Root.Clear();


            //메인 루트들을 만들어주자
            //_rootUnit_Overall =		AddUnit_OnlyButton(null, "Portrait", CATEGORY.Overall_Name, null, true, null);
            _rootUnit_Overall   = AddUnit_Label(null, Editor.GetUIWord(UIWORD.RootUnits), CATEGORY.Overall_Name, null, true, null);
            _rootUnit_Image     = AddUnit_Label(null, Editor.GetUIWord(UIWORD.Images), CATEGORY.Images_Name, null, true, null);
            _rootUnit_Mesh      = AddUnit_Label(null, Editor.GetUIWord(UIWORD.Meshes), CATEGORY.Mesh_Name, null, true, null);
            _rootUnit_MeshGroup = AddUnit_Label(null, Editor.GetUIWord(UIWORD.MeshGroups), CATEGORY.MeshGroup_Name, null, true, null);
            //_rootUnit_Face =		AddUnit_Label(null, "Faces", CATEGORY.Face_Name, null, true, null);
            _rootUnit_Animation = AddUnit_Label(null, Editor.GetUIWord(UIWORD.AnimationClips), CATEGORY.Animation_Name, null, true, null);
            _rootUnit_Param     = AddUnit_Label(null, Editor.GetUIWord(UIWORD.ControlParameters), CATEGORY.Param_Name, null, true, null);

            if (Editor == null || Editor._portrait == null)
            {
                return;
            }

            List <apRootUnit> rootUnits = Editor._portrait._rootUnits;

            for (int i = 0; i < rootUnits.Count; i++)
            {
                apRootUnit rootUnit = rootUnits[i];
                AddUnit_ToggleButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Root), "Root Unit " + i, CATEGORY.Overall_Item, rootUnit, false, _rootUnit_Overall);
            }


            //1. 이미지 파일들을 검색하자
            List <apTextureData> textures = Editor._portrait._textureData;

            for (int i = 0; i < textures.Count; i++)
            {
                apTextureData textureData = textures[i];
                AddUnit_ToggleButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Image), textureData._name, CATEGORY.Images_Item, textureData, false, _rootUnit_Image);
            }
            AddUnit_OnlyButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Add), Editor.GetUIWord(UIWORD.AddImage), CATEGORY.Images_Add, null, false, _rootUnit_Image);
            AddUnit_OnlyButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_AddPSD), Editor.GetUIWord(UIWORD.ImportPSDFile), CATEGORY.Images_AddPSD, null, false, _rootUnit_Image);            //추가 : PSD

            //2. 메시 들을 검색하자
            List <apMesh> meshes = Editor._portrait._meshes;

            for (int i = 0; i < meshes.Count; i++)
            {
                apMesh mesh = meshes[i];
                AddUnit_ToggleButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Mesh), mesh._name, CATEGORY.Mesh_Item, mesh, false, _rootUnit_Mesh);
            }
            AddUnit_OnlyButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Add), Editor.GetUIWord(UIWORD.AddMesh), CATEGORY.Mesh_Add, null, false, _rootUnit_Mesh);

            //3. 메시 그룹들을 검색하자
            //메시 그룹들은 하위에 또다른 Mesh Group을 가지고 있다.
            List <apMeshGroup> meshGroups = Editor._portrait._meshGroups;

            for (int i = 0; i < meshGroups.Count; i++)
            {
                apMeshGroup meshGroup = meshGroups[i];

                if (meshGroup._parentMeshGroup == null || meshGroup._parentMeshGroupID < 0)
                {
                    //Debug.Log("Reset H : MeshGroup(" + meshGroup._name + ") - Root");
                    apEditorHierarchyUnit addedHierarchyUnit = AddUnit_ToggleButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_MeshGroup), meshGroup._name, CATEGORY.MeshGroup_Item, meshGroup, false, _rootUnit_MeshGroup);
                    if (meshGroup._childMeshGroupTransforms.Count > 0)
                    {
                        AddUnit_SubMeshGroup(meshGroup, addedHierarchyUnit);
                    }
                }
                else
                {
                    //Debug.Log("Reset H : MeshGroup(" + meshGroup._name + ") - Child");
                }
            }
            AddUnit_OnlyButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Add), Editor.GetUIWord(UIWORD.AddMeshGroup), CATEGORY.MeshGroup_Add, null, false, _rootUnit_MeshGroup);


            //7. 파라미터들을 검색하자
            List <apControlParam> cParams = Editor.ParamControl._controlParams;

            for (int i = 0; i < cParams.Count; i++)
            {
                apControlParam cParam = cParams[i];
                AddUnit_ToggleButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Param),
                                     cParam._keyName,
                                     CATEGORY.Param_Item,
                                     cParam,
                                     false,
                                     _rootUnit_Param);
            }
            AddUnit_OnlyButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Add), Editor.GetUIWord(UIWORD.AddControlParameter), CATEGORY.Param_Add, null, false, _rootUnit_Param);


            //8. 애니메이션을 넣자
            List <apAnimClip> animClips = Editor._portrait._animClips;

            for (int i = 0; i < animClips.Count; i++)
            {
                apAnimClip animClip = animClips[i];
                AddUnit_ToggleButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Animation),
                                     animClip._name,
                                     CATEGORY.Animation_Item,
                                     animClip,
                                     false,
                                     _rootUnit_Animation);
            }
            AddUnit_OnlyButton(Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Add), Editor.GetUIWord(UIWORD.AddAnimationClip), CATEGORY.Animation_Add, null, false, _rootUnit_Animation);
        }
Exemplo n.º 7
0
        // Click Event
        //-----------------------------------------------------------------------------------------
        public void OnUnitClick(apEditorHierarchyUnit eventUnit, int savedKey, object savedObj)
        {
            if (Editor == null)
            {
                return;
            }

            apEditorHierarchyUnit selectedUnit = null;


            //여기서 이벤트를 설정해주자
            CATEGORY category = (CATEGORY)savedKey;

            //Debug.Log("Unit Select : " + category);
            switch (category)
            {
            case CATEGORY.Overall_Name:
            case CATEGORY.Images_Name:
            case CATEGORY.Mesh_Name:
            case CATEGORY.MeshGroup_Name:
            //case CATEGORY.Face_Name:
            case CATEGORY.Animation_Name:
            case CATEGORY.Param_Name:
                break;

            case CATEGORY.Overall_Item:
                //전체 선택
                apRootUnit rootUnit = savedObj as apRootUnit;
                if (rootUnit != null)
                {
                    Editor.Select.SetOverall(rootUnit);
                    if (Editor.Select.RootUnit == rootUnit)
                    {
                        selectedUnit = eventUnit;
                    }
                }
                break;

            case CATEGORY.Images_Item:
            {
                apTextureData textureData = savedObj as apTextureData;
                if (textureData != null)
                {
                    Editor.Select.SetImage(textureData);                                    //<< 선택하자
                    if (Editor.Select.TextureData == textureData)
                    {
                        selectedUnit = eventUnit;
                    }
                }
            }
            break;

            case CATEGORY.Images_Add:
                Editor.Controller.AddImage();
                break;

            case CATEGORY.Images_AddPSD:                    //추가 : PSD 로드
                Editor.Controller.ShowPSDLoadDialog();
                break;

            case CATEGORY.Mesh_Item:
            {
                apMesh mesh = savedObj as apMesh;
                if (mesh != null)
                {
                    Editor.Select.SetMesh(mesh);                                    //<< 선택하자

                    if (Editor.Select.Mesh == mesh)
                    {
                        selectedUnit = eventUnit;
                    }
                }
            }
            break;

            case CATEGORY.Mesh_Add:
                Editor.Controller.AddMesh();
                break;

            case CATEGORY.MeshGroup_Item:
            {
                apMeshGroup meshGroup = savedObj as apMeshGroup;
                if (meshGroup != null)
                {
                    Editor.Select.SetMeshGroup(meshGroup);

                    if (Editor.Select.MeshGroup == meshGroup)
                    {
                        selectedUnit = eventUnit;
                    }
                }
            }
            break;

            case CATEGORY.MeshGroup_Add:
                Editor.Controller.AddMeshGroup();
                break;

            //case CATEGORY.Face_Item:
            //	break;

            //case CATEGORY.Face_Add:
            //	break;

            case CATEGORY.Animation_Item:
            {
                apAnimClip animClip = savedObj as apAnimClip;
                if (animClip != null)
                {
                    Editor.Select.SetAnimClip(animClip);
                    if (Editor.Select.AnimClip == animClip)
                    {
                        selectedUnit = eventUnit;
                    }
                }
            }
            break;

            case CATEGORY.Animation_Add:
            {
                //데모 기능 제한
                //Param 개수는 2개로 제한되며, 이걸 넘어가면 추가할 수 없다.
                if (apVersion.I.IsDemo)
                {
                    if (Editor._portrait._animClips.Count >= 2)
                    {
                        //이미 2개를 넘었다.
                        EditorUtility.DisplayDialog(
                            Editor.GetText(TEXT.DemoLimitation_Title),
                            Editor.GetText(TEXT.DemoLimitation_Body_AddAnimation),
                            Editor.GetText(TEXT.Okay)
                            );

                        break;
                    }
                }

                Editor.Controller.AddAnimClip();
            }

            break;

            case CATEGORY.Param_Item:
            {
                apControlParam cParam = savedObj as apControlParam;
                if (cParam != null)
                {
                    Editor.Select.SetParam(cParam);

                    if (Editor.Select.Param == cParam)
                    {
                        selectedUnit = eventUnit;
                    }
                }
            }
            break;

            case CATEGORY.Param_Add:
            {
                //데모 기능 제한
                //Param 개수는 2개로 제한되며, 이걸 넘어가면 추가할 수 없다.
                if (apVersion.I.IsDemo)
                {
                    if (Editor.ParamControl._controlParams.Count >= 2)
                    {
                        //이미 2개를 넘었다.
                        EditorUtility.DisplayDialog(
                            Editor.GetText(TEXT.DemoLimitation_Title),
                            Editor.GetText(TEXT.DemoLimitation_Body_AddParam),
                            Editor.GetText(TEXT.Okay)
                            );

                        break;
                    }
                }

                //Param 추가
                Editor.Controller.AddParam();
            }

            break;
            }

            if (selectedUnit != null)
            {
                for (int i = 0; i < _units_All.Count; i++)
                {
                    if (_units_All[i] == selectedUnit)
                    {
                        //_units_All[i]._isSelected = true;
                        _units_All[i].SetSelected(true);
                    }
                    else
                    {
                        //_units_All[i]._isSelected = false;
                        _units_All[i].SetSelected(false);
                    }
                }
            }
            else
            {
                for (int i = 0; i < _units_All.Count; i++)
                {
                    //_units_All[i]._isSelected = false;
                    _units_All[i].SetSelected(false);
                }
            }
        }
Exemplo n.º 8
0
        // Refresh (without Reset)
        //-----------------------------------------------------------------------------------------
        public void RefreshUnits()
        {
            if (Editor == null || Editor._portrait == null || _isNeedReset)
            {
                ResetAllUnits();

                return;
            }

            List <apEditorHierarchyUnit> deletedUnits = new List <apEditorHierarchyUnit>();
            //0. 루트 유닛들을 검색하자
            List <apRootUnit> rootUnits = Editor._portrait._rootUnits;

            for (int i = 0; i < rootUnits.Count; i++)
            {
                apRootUnit rootUnit = Editor._portrait._rootUnits[i];
                RefreshUnit(CATEGORY.Overall_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Root),
                            rootUnit,
                            "Root Unit " + i,
                            Editor.Select.RootUnit,
                            _rootUnit_Overall);
            }
            CheckRemovableUnits <apRootUnit>(deletedUnits, CATEGORY.Overall_Item, rootUnits);


            //1. 이미지 파일들을 검색하자 -> 있는건 없애고, 없는건 만들자
            List <apTextureData> textures = Editor._portrait._textureData;

            for (int i = 0; i < textures.Count; i++)
            {
                apTextureData textureData = textures[i];
                RefreshUnit(CATEGORY.Images_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Image),
                            textureData,
                            textureData._name,
                            Editor.Select.TextureData,
                            _rootUnit_Image);
            }

            CheckRemovableUnits <apTextureData>(deletedUnits, CATEGORY.Images_Item, textures);



            //2. 메시 들을 검색하자
            List <apMesh> meshes = Editor._portrait._meshes;

            for (int i = 0; i < meshes.Count; i++)
            {
                apMesh mesh = meshes[i];
                RefreshUnit(CATEGORY.Mesh_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Mesh),
                            mesh,
                            mesh._name,
                            Editor.Select.Mesh,
                            _rootUnit_Mesh);
            }

            CheckRemovableUnits <apMesh>(deletedUnits, CATEGORY.Mesh_Item, meshes);

            //3. Mesh Group들을 검색하자
            List <apMeshGroup> meshGroups = Editor._portrait._meshGroups;

            for (int i = 0; i < meshGroups.Count; i++)
            {
                //이건 재귀 함수 -_-;
                if (meshGroups[i]._parentMeshGroup == null)
                {
                    RefreshUnit_MeshGroup(meshGroups[i], _rootUnit_MeshGroup);
                }
            }
            CheckRemovableUnits <apMeshGroup>(deletedUnits, CATEGORY.MeshGroup_Item, meshGroups);

            //7. 파라미터들을 검색하자
            List <apControlParam> cParams = Editor.ParamControl._controlParams;

            for (int i = 0; i < cParams.Count; i++)
            {
                apControlParam cParam = cParams[i];
                RefreshUnit(CATEGORY.Param_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Param),
                            cParam,
                            cParam._keyName,
                            Editor.Select.Param,
                            _rootUnit_Param);

                CheckRemovableUnits <apControlParam>(deletedUnits, CATEGORY.Param_Item, cParams);
            }


            //8. 애니메이션을 넣자
            List <apAnimClip> animClips = Editor._portrait._animClips;

            for (int i = 0; i < animClips.Count; i++)
            {
                apAnimClip animClip = animClips[i];
                RefreshUnit(CATEGORY.Animation_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Animation),
                            animClip,
                            animClip._name,
                            Editor.Select.AnimClip,
                            _rootUnit_Animation);

                CheckRemovableUnits <apAnimClip>(deletedUnits, CATEGORY.Animation_Item, animClips);
            }

            //삭제할 유닛을 체크하고 계산하자
            for (int i = 0; i < deletedUnits.Count; i++)
            {
                //1. 먼저 All에서 없앤다.
                //2. Parent가 있는경우,  Parent에서 없애달라고 한다.


                apEditorHierarchyUnit dUnit = deletedUnits[i];
                if (dUnit._parentUnit != null)
                {
                    dUnit._parentUnit._childUnits.Remove(dUnit);
                }

                _units_All.Remove(dUnit);
            }

            //전체 Sort를 한다.
            //재귀적으로 실행
            for (int i = 0; i < _units_Root.Count; i++)
            {
                SortUnit_Recv(_units_Root[i]);
            }
        }
        // Refresh (without Reset)
        //-----------------------------------------------------------------------------------------
        public void RefreshUnits()
        {
            if (Editor == null || Editor._portrait == null || _isNeedReset)
            {
                ResetAllUnits();

                return;
            }

            ReloadGUIContent();

            List <apEditorHierarchyUnit> deletedUnits = new List <apEditorHierarchyUnit>();

            //0. 루트 유닛들을 검색하자
            //이전
            //List<apRootUnit> rootUnits = Editor._portrait._rootUnits;

            //변경
            List <apObjectOrders.OrderSet> rootUnitSets = Editor._portrait._objectOrders.RootUnits;

            for (int i = 0; i < rootUnitSets.Count; i++)
            {
                //이전
                //apRootUnit rootUnit = Editor._portrait._rootUnits[i];

                //변경
                apRootUnit rootUnit = rootUnitSets[i]._linked_RootUnit;
                RefreshUnit(CATEGORY.Overall_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Root),
                            rootUnit,
                            "Root Unit " + i + " (" + rootUnit.Name + ")",                                    //<<변경
                            Editor.Select.RootUnit,
                            _rootUnit_Overall,
                            i);
            }
            //이전
            //CheckRemovableUnits<apRootUnit>(deletedUnits, CATEGORY.Overall_Item, rootUnits);

            //변경
            CheckRemovableUnits <apRootUnit>(deletedUnits, CATEGORY.Overall_Item, Editor._portrait._rootUnits);


            //1. 이미지 파일들을 검색하자 -> 있는건 없애고, 없는건 만들자
            //이전
            //List<apTextureData> textures = Editor._portrait._textureData;

            //변경
            List <apObjectOrders.OrderSet> textureSets = Editor._portrait._objectOrders.Images;

            for (int i = 0; i < textureSets.Count; i++)
            {
                //이전
                //apTextureData textureData = textures[i];

                //변경
                apTextureData textureData = textureSets[i]._linked_Image;
                RefreshUnit(CATEGORY.Images_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Image),
                            textureData,
                            textureData._name,
                            Editor.Select.TextureData,
                            _rootUnit_Image,
                            i);
            }
            //이전
            //CheckRemovableUnits<apTextureData>(deletedUnits, CATEGORY.Images_Item, textures);

            //변경
            CheckRemovableUnits <apTextureData>(deletedUnits, CATEGORY.Images_Item, Editor._portrait._textureData);



            //2. 메시 들을 검색하자
            //이전
            //List<apMesh> meshes = Editor._portrait._meshes;

            //변경
            List <apObjectOrders.OrderSet> mesheSets = Editor._portrait._objectOrders.Meshes;

            for (int i = 0; i < mesheSets.Count; i++)
            {
                //이전
                //apMesh mesh = meshes[i];

                //변경
                apMesh mesh = mesheSets[i]._linked_Mesh;
                RefreshUnit(CATEGORY.Mesh_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Mesh),
                            mesh,
                            mesh._name,
                            Editor.Select.Mesh,
                            _rootUnit_Mesh,
                            i);
            }
            //이전
            //CheckRemovableUnits<apMesh>(deletedUnits, CATEGORY.Mesh_Item, meshes);

            //변경
            CheckRemovableUnits <apMesh>(deletedUnits, CATEGORY.Mesh_Item, Editor._portrait._meshes);


            //3. Mesh Group들을 검색하자
            //이전
            //List<apMeshGroup> meshGroups = Editor._portrait._meshGroups;
            //변경
            List <apObjectOrders.OrderSet> meshGroupSets = Editor._portrait._objectOrders.MeshGroups;

            for (int i = 0; i < meshGroupSets.Count; i++)
            {
                //이건 재귀 함수 -_-;
                apMeshGroup meshGroup = meshGroupSets[i]._linked_MeshGroup;
                if (meshGroup._parentMeshGroup == null)
                {
                    RefreshUnit_MeshGroup(meshGroup, _rootUnit_MeshGroup, i);
                }
            }
            //이전
            //CheckRemovableUnits<apMeshGroup>(deletedUnits, CATEGORY.MeshGroup_Item, meshGroups);

            //변경
            CheckRemovableUnits <apMeshGroup>(deletedUnits, CATEGORY.MeshGroup_Item, Editor._portrait._meshGroups);


            //7. 파라미터들을 검색하자
            //이전
            //List<apControlParam> cParams = Editor.ParamControl._controlParams;

            //변경
            List <apObjectOrders.OrderSet> cParamSets = Editor._portrait._objectOrders.ControlParams;

            for (int i = 0; i < cParamSets.Count; i++)
            {
                //이전
                //apControlParam cParam = cParams[i];

                //변경
                apControlParam cParam = cParamSets[i]._linked_ControlParam;
                RefreshUnit(CATEGORY.Param_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Param),
                            cParam,
                            cParam._keyName,
                            Editor.Select.Param,
                            _rootUnit_Param,
                            i);
            }
            //이전
            //CheckRemovableUnits<apControlParam>(deletedUnits, CATEGORY.Param_Item, cParams);

            //변경
            CheckRemovableUnits <apControlParam>(deletedUnits, CATEGORY.Param_Item, Editor.ParamControl._controlParams);


            //8. 애니메이션을 넣자
            //이전
            //List<apAnimClip> animClips = Editor._portrait._animClips;

            List <apObjectOrders.OrderSet> animClipSets = Editor._portrait._objectOrders.AnimClips;

            for (int i = 0; i < animClipSets.Count; i++)
            {
                //이전
                //apAnimClip animClip = animClips[i];
                //변경
                apAnimClip animClip = animClipSets[i]._linked_AnimClip;
                RefreshUnit(CATEGORY.Animation_Item,
                            Editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Animation),
                            animClip,
                            animClip._name,
                            Editor.Select.AnimClip,
                            _rootUnit_Animation,
                            i);
            }
            //이전
            //CheckRemovableUnits<apAnimClip>(deletedUnits, CATEGORY.Animation_Item, animClips);

            //변경
            CheckRemovableUnits <apAnimClip>(deletedUnits, CATEGORY.Animation_Item, Editor._portrait._animClips);

            //삭제할 유닛을 체크하고 계산하자
            for (int i = 0; i < deletedUnits.Count; i++)
            {
                //1. 먼저 All에서 없앤다.
                //2. Parent가 있는경우,  Parent에서 없애달라고 한다.


                apEditorHierarchyUnit dUnit = deletedUnits[i];
                if (dUnit._parentUnit != null)
                {
                    dUnit._parentUnit._childUnits.Remove(dUnit);
                }

                _units_All.Remove(dUnit);
            }

            //전체 Sort를 한다.
            //재귀적으로 실행
            for (int i = 0; i < _units_Root.Count; i++)
            {
                SortUnit_Recv(_units_Root[i]);
            }
        }
        public void OnUnitClickOrderChanged(apEditorHierarchyUnit eventUnit, int savedKey, object savedObj, bool isOrderUp)
        {
            //Hierarchy의 항목 순서를 바꾸자
            if (Editor == null || Editor._portrait == null)
            {
                return;
            }
            apObjectOrders orders = Editor._portrait._objectOrders;

            bool     isChanged = false;
            bool     isResult  = false;
            CATEGORY category  = (CATEGORY)savedKey;

            switch (category)
            {
            case CATEGORY.Overall_Item:
            {
                apRootUnit rootUnit = savedObj as apRootUnit;
                if (rootUnit != null)
                {
                    isResult = orders.ChangeOrder(Editor._portrait, apObjectOrders.OBJECT_TYPE.RootUnit, rootUnit._childMeshGroup._uniqueID, isOrderUp);
                    if (isResult)
                    {
                        isChanged = true;
                    }
                }
            }
            break;

            case CATEGORY.Images_Item:
            {
                apTextureData textureData = savedObj as apTextureData;
                if (textureData != null)
                {
                    isResult = orders.ChangeOrder(Editor._portrait, apObjectOrders.OBJECT_TYPE.Image, textureData._uniqueID, isOrderUp);
                    if (isResult)
                    {
                        isChanged = true;
                    }
                }
            }
            break;

            case CATEGORY.Mesh_Item:
            {
                apMesh mesh = savedObj as apMesh;
                if (mesh != null)
                {
                    isResult = orders.ChangeOrder(Editor._portrait, apObjectOrders.OBJECT_TYPE.Mesh, mesh._uniqueID, isOrderUp);
                    if (isResult)
                    {
                        isChanged = true;
                    }
                }
            }
            break;

            case CATEGORY.MeshGroup_Item:
            {
                apMeshGroup meshGroup = savedObj as apMeshGroup;
                if (meshGroup != null)
                {
                    isResult = orders.ChangeOrder(Editor._portrait, apObjectOrders.OBJECT_TYPE.MeshGroup, meshGroup._uniqueID, isOrderUp);
                    if (isResult)
                    {
                        isChanged = true;
                    }
                }
            }
            break;

            case CATEGORY.Animation_Item:
            {
                apAnimClip animClip = savedObj as apAnimClip;
                if (animClip != null)
                {
                    isResult = orders.ChangeOrder(Editor._portrait, apObjectOrders.OBJECT_TYPE.AnimClip, animClip._uniqueID, isOrderUp);
                    if (isResult)
                    {
                        isChanged = true;
                    }
                }
            }
            break;

            case CATEGORY.Param_Item:
            {
                apControlParam cParam = savedObj as apControlParam;
                if (cParam != null)
                {
                    isResult = orders.ChangeOrder(Editor._portrait, apObjectOrders.OBJECT_TYPE.ControlParam, cParam._uniqueID, isOrderUp);
                    if (isResult)
                    {
                        isChanged = true;
                    }
                }
            }
            break;
            }

            if (isChanged)
            {
                apEditorUtil.SetEditorDirty();
                Editor.RefreshControllerAndHierarchy(false);
            }
        }
Exemplo n.º 11
0
 public void SetRootUnit(apRootUnit rootUnit, int regOrder)
 {
     SetData(OBJECT_TYPE.RootUnit, rootUnit._childMeshGroup._uniqueID, regOrder);
     _linked_RootUnit = rootUnit;
 }
Exemplo n.º 12
0
        // Change Order
        //------------------------------------------------------------
        public bool ChangeOrder(apPortrait portrait, OBJECT_TYPE objectType, int ID, bool isOrderUp)
        {
            //Debug.Log("ChangeOrder : " + objectType + " / " + ID + " / Up : " + isOrderUp);

            //1. 타겟이 있는지 확인
            List <OrderSet> orderSets = _orderSets[objectType];
            OrderSet        target    = orderSets.Find(delegate(OrderSet a)
            {
                return(a._ID == ID);
            });

            if (target == null)
            {
                return(false);
            }
            if (objectType == OBJECT_TYPE.MeshGroup)
            {
                //MeshGroup이 없거나 자식 MeshGroup이면 순서를 바꿀 수 없다.
                if (target._linked_MeshGroup == null)
                {
                    return(false);
                }
                if (target._linked_MeshGroup._parentMeshGroup != null)
                {
                    return(false);
                }
            }

            //Order Up : order 값이 1 줄어든다.
            //Order Down : order 값이 1 증가한다.
            //자리가 바뀔 대상을 찾는다.
            //단, MeshGroup은 Parent가 없는 것들이어야 한다.

            int prevOrder = target._customOrder;
            int nextOrder = isOrderUp ? (prevOrder - 1) : (prevOrder + 1);

            OrderSet switchTarget = null;

            if (objectType == OBJECT_TYPE.MeshGroup)
            {
                switchTarget = orderSets.Find(delegate(OrderSet a)
                {
                    if (a._linked_MeshGroup == null)
                    {
                        return(false);
                    }
                    if (a._linked_MeshGroup._parentMeshGroup != null)
                    {
                        return(false);
                    }
                    //MeshGroup이 null이거나 하위 MeshGroup이면 패스

                    return(a._customOrder == nextOrder && a != target);
                });
            }
            else
            {
                switchTarget = orderSets.Find(delegate(OrderSet a)
                {
                    return(a._customOrder == nextOrder && a != target);
                });
            }

            if (switchTarget != null)
            {
                //서로의 Order 값을 바꾼다.
                switchTarget._customOrder = prevOrder;
                target._customOrder       = nextOrder;

                //Debug.Log("자리 바꾸기 : " + target.Name + " <-> " + switchTarget.Name);

                SortByCustom();

                //만약 RootUnit의 경우라면, Portrait에서의 RootUnit 인덱스를 교환할 필요도 있다.
                if (objectType == OBJECT_TYPE.RootUnit)
                {
                    portrait._mainMeshGroupIDList.Clear();
                    portrait._rootUnits.Clear();

                    for (int i = 0; i < orderSets.Count; i++)
                    {
                        apRootUnit rootUnit = orderSets[i]._linked_RootUnit;
                        portrait._mainMeshGroupIDList.Add(rootUnit._childMeshGroup._uniqueID);
                        portrait._rootUnits.Add(rootUnit);
                    }
                }
                return(true);
            }
            //else
            //{
            //	Debug.LogError("자리 바꾸기 실패 : " + target.Name);
            //}

            return(false);
        }
Exemplo n.º 13
0
        // Functions
        //----------------------------------------------------
        public void Sync(apPortrait portrait)
        {
            //Debug.Log("Sync : " + portrait.name);
            List <apRootUnit>     rootUnits     = portrait._rootUnits;
            List <apTextureData>  images        = portrait._textureData;
            List <apMesh>         meshes        = portrait._meshes;
            List <apMeshGroup>    meshGroups    = portrait._meshGroups;
            List <apAnimClip>     animClips     = portrait._animClips;
            List <apControlParam> controlParams = portrait._controller._controlParams;


            //일단 모두 초기화
            foreach (KeyValuePair <OBJECT_TYPE, List <OrderSet> > subOrderSet in _orderSets)
            {
                List <OrderSet> orderSets = subOrderSet.Value;
                for (int i = 0; i < orderSets.Count; i++)
                {
                    orderSets[i]._isExist = false;                    //<<플래그를 세운다. (응?)
                }
            }

            OrderSet        existOrderSet = null;
            List <OrderSet> newOrderSets  = new List <OrderSet>();

            //1. Root Unit
            apRootUnit curRootUnit = null;

            for (int i = 0; i < rootUnits.Count; i++)
            {
                curRootUnit = rootUnits[i];
                if (curRootUnit == null || curRootUnit._childMeshGroup == null)
                {
                    continue;
                }

                existOrderSet = _orderSets_RootUnit.Find(delegate(OrderSet a)
                {
                    return(a._ID == curRootUnit._childMeshGroup._uniqueID);
                });

                if (existOrderSet != null)
                {
                    //이미 등록된 OrderSet이다.
                    existOrderSet._isExist         = true;
                    existOrderSet._regOrder        = i;
                    existOrderSet._linked_RootUnit = curRootUnit;
                }
                else
                {
                    //아직 등록되지 않은 OrderSet이다.
                    OrderSet newOrderSet = new OrderSet();
                    newOrderSet.SetRootUnit(curRootUnit, i);
                    newOrderSets.Add(newOrderSet);
                }
            }

            //2. Images
            apTextureData curImage = null;

            for (int i = 0; i < images.Count; i++)
            {
                curImage = images[i];
                if (curImage == null)
                {
                    continue;
                }

                existOrderSet = _orderSets_Image.Find(delegate(OrderSet a)
                {
                    return(a._ID == curImage._uniqueID);
                });

                if (existOrderSet != null)
                {
                    //이미 등록된 OrderSet이다.
                    existOrderSet._isExist      = true;
                    existOrderSet._regOrder     = i;
                    existOrderSet._linked_Image = curImage;
                }
                else
                {
                    //아직 등록되지 않은 OrderSet이다.
                    OrderSet newOrderSet = new OrderSet();
                    newOrderSet.SetImage(curImage, i);
                    newOrderSets.Add(newOrderSet);
                }
            }

            //3. Meshes
            apMesh curMesh = null;

            for (int i = 0; i < meshes.Count; i++)
            {
                curMesh = meshes[i];
                if (curMesh == null)
                {
                    continue;
                }

                existOrderSet = _orderSets_Mesh.Find(delegate(OrderSet a)
                {
                    return(a._ID == curMesh._uniqueID);
                });

                if (existOrderSet != null)
                {
                    //이미 등록된 OrderSet이다.
                    existOrderSet._isExist     = true;
                    existOrderSet._regOrder    = i;
                    existOrderSet._linked_Mesh = curMesh;
                }
                else
                {
                    //아직 등록되지 않은 OrderSet이다.
                    OrderSet newOrderSet = new OrderSet();
                    newOrderSet.SetMesh(curMesh, i);
                    newOrderSets.Add(newOrderSet);
                }
            }

            //4. MeshGroup
            apMeshGroup curMeshGroup = null;

            for (int i = 0; i < meshGroups.Count; i++)
            {
                curMeshGroup = meshGroups[i];
                if (curMeshGroup == null)
                {
                    continue;
                }
                //자식 MeshGroup인 경우 처리하지 않는다.
                if (curMeshGroup._parentMeshGroup != null)
                {
                    continue;
                }

                existOrderSet = _orderSets_MeshGroup.Find(delegate(OrderSet a)
                {
                    return(a._ID == curMeshGroup._uniqueID);
                });

                if (existOrderSet != null)
                {
                    //이미 등록된 OrderSet이다.
                    existOrderSet._isExist          = true;
                    existOrderSet._regOrder         = i;
                    existOrderSet._linked_MeshGroup = curMeshGroup;
                }
                else
                {
                    //아직 등록되지 않은 OrderSet이다.
                    OrderSet newOrderSet = new OrderSet();
                    newOrderSet.SetMeshGroup(curMeshGroup, i);
                    newOrderSets.Add(newOrderSet);
                }
            }

            //5. AnimClip
            apAnimClip curAnimClip = null;

            for (int i = 0; i < animClips.Count; i++)
            {
                curAnimClip = animClips[i];
                if (curAnimClip == null)
                {
                    continue;
                }

                existOrderSet = _orderSets_AnimClip.Find(delegate(OrderSet a)
                {
                    return(a._ID == curAnimClip._uniqueID);
                });

                if (existOrderSet != null)
                {
                    //이미 등록된 OrderSet이다.
                    existOrderSet._isExist         = true;
                    existOrderSet._regOrder        = i;
                    existOrderSet._linked_AnimClip = curAnimClip;
                }
                else
                {
                    //아직 등록되지 않은 OrderSet이다.
                    OrderSet newOrderSet = new OrderSet();
                    newOrderSet.SetAnimClip(curAnimClip, i);
                    newOrderSets.Add(newOrderSet);
                }
            }

            //6. Control Param
            apControlParam curControlParam = null;

            for (int i = 0; i < controlParams.Count; i++)
            {
                curControlParam = controlParams[i];
                if (curControlParam == null)
                {
                    continue;
                }

                existOrderSet = _orderSets_ControlParam.Find(delegate(OrderSet a)
                {
                    return(a._ID == curControlParam._uniqueID);
                });

                if (existOrderSet != null)
                {
                    //이미 등록된 OrderSet이다.
                    existOrderSet._isExist             = true;
                    existOrderSet._regOrder            = i;
                    existOrderSet._linked_ControlParam = curControlParam;
                }
                else
                {
                    //아직 등록되지 않은 OrderSet이다.
                    OrderSet newOrderSet = new OrderSet();
                    newOrderSet.SetControlParam(curControlParam, i);
                    newOrderSets.Add(newOrderSet);
                }
            }

            bool isAnyChanged = false;

            // 연결이 안된 OrderSet 을 삭제
            foreach (KeyValuePair <OBJECT_TYPE, List <OrderSet> > subOrderSet in _orderSets)
            {
                List <OrderSet> orderSets = subOrderSet.Value;
                int             nRemoved  = orderSets.RemoveAll(delegate(OrderSet a)
                {
                    return(!a._isExist);
                });

                if (nRemoved > 0)
                {
                    isAnyChanged = true;
                }
            }

            //새로 추가될 OrderSet을 추가한다. 이때, Order를 잘 체크하자
            if (newOrderSets.Count > 0)
            {
                isAnyChanged = true;

                OrderSet        newOrderSet = null;
                List <OrderSet> targetList  = null;
                for (int i = 0; i < newOrderSets.Count; i++)
                {
                    newOrderSet = newOrderSets[i];
                    targetList  = _orderSets[newOrderSet._objectType];

                    newOrderSet.SetOrder(targetList.Count);         //리스트의 크기만큼의 Order값을 넣자

                    targetList.Add(newOrderSet);                    //<<리스트에 추가!
                }
            }

            if (isAnyChanged)
            {
                //Sort를 하고 CustomOrder를 작성하자
                foreach (KeyValuePair <OBJECT_TYPE, List <OrderSet> > subOrderSet in _orderSets)
                {
                    List <OrderSet> orderSets = subOrderSet.Value;
                    orderSets.Sort(delegate(OrderSet a, OrderSet b)
                    {
                        return(a._customOrder - b._customOrder);                       //오름차순
                    });

                    for (int i = 0; i < orderSets.Count; i++)
                    {
                        orderSets[i]._customOrder = i;
                    }
                }
            }

            //Debug.Log("Root Units : " + _orderSets[OBJECT_TYPE.RootUnit].Count);
            //Debug.Log("Images : " + _orderSets[OBJECT_TYPE.Image].Count);
            //Debug.Log("Meshes : " + _orderSets[OBJECT_TYPE.Mesh].Count);
            //Debug.Log("Mesh Groups : " + _orderSets[OBJECT_TYPE.MeshGroup].Count);
            //Debug.Log("AnimClips : " + _orderSets[OBJECT_TYPE.AnimClip].Count);
            //Debug.Log("Control Params : " + _orderSets[OBJECT_TYPE.ControlParam].Count);
        }