Beispiel #1
0
        private void RefreshImagePreview()
        {
            _srcTexureData    = null;
            _dstTexureData    = null;
            _isImageChangable = false;

            if (_modMesh._isMeshTransform && _modMesh._transform_Mesh != null)
            {
                if (_modMesh._transform_Mesh._mesh != null &&
                    _modMesh._transform_Mesh._mesh._textureData_Linked != null)
                {
                    apTextureData linkedTextureData = _modMesh._transform_Mesh._mesh._textureData_Linked;

                    _isImageChangable = true;

                    _srcTexureData = linkedTextureData;

                    if (_modMesh._extraValue._textureDataID >= 0)
                    {
                        _dstTexureData = _portrait.GetTexture(_modMesh._extraValue._textureDataID);
                        if (_dstTexureData == null)
                        {
                            _modMesh._extraValue._textureDataID = -1;
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public void Link(apPortrait portrait)
 {
     if (_textureDataID >= 0)
     {
         _linkedTextureData = portrait.GetTexture(_textureDataID);
     }
 }
 public void CopyFromSrc(ImageTexturePair src)
 {
     _textureDataID     = src._textureDataID;
     _targetTextureData = src._targetTextureData;
     _textureAssetPath  = src._textureAssetPath;
     _textureAsset      = src._textureAsset;
 }
        // Show Window
        //------------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apTextureData targetTextureData, FUNC_SELECT_TEXTUREASSET_RESULT funcResult)
        {
            CloseDialog();

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

            EditorWindow curWindow = EditorWindow.GetWindow(typeof(apDialog_SelectTextureAsset), true, "Select Texture2D", true);
            apDialog_SelectTextureAsset curTool = curWindow as apDialog_SelectTextureAsset;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                int width  = 500;
                int height = 600;
                s_window          = curTool;
                s_window.position = new Rect((editor.position.xMin + editor.position.xMax) / 2 - (width / 2),
                                             (editor.position.yMin + editor.position.yMax) / 2 - (height / 2),
                                             width, height);
                s_window.Init(editor, targetTextureData, loadKey, funcResult);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        private void OnTextureDataSelected(bool isSuccess, apMesh targetMesh, object loadKey, apTextureData resultTextureData)
        {
            if (!isSuccess)
            {
                _loadKey_TextureSelect = null;
                return;
            }

            if (_loadKey_TextureSelect != loadKey)
            {
                _loadKey_TextureSelect = null;
                return;
            }

            _loadKey_TextureSelect = null;

            apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

            //일단 초기화
            _modMesh._extraValue._textureDataID     = -1;
            _modMesh._extraValue._linkedTextureData = null;
            _dstTexureData = null;


            if (_modMesh != null && _modMesh._isMeshTransform && _modMesh._transform_Mesh != null)
            {
                if (resultTextureData != null)
                {
                    _modMesh._extraValue._textureDataID = resultTextureData._uniqueID;
                }
            }


            if (_modMesh._extraValue._textureDataID >= 0)
            {
                _dstTexureData = _portrait.GetTexture(_modMesh._extraValue._textureDataID);
                _modMesh._extraValue._linkedTextureData = _dstTexureData;

                if (_dstTexureData == null)
                {
                    _modMesh._extraValue._textureDataID = -1;
                }
            }

            RefreshImagePreview();

            Repaint();


            _meshGroup.RefreshModifierLink();            //<<Modifier Link를 다시 해야한다.
            _editor.SetRepaint();
        }
        // Bake
        //--------------------------------------------------
        /// <summary>
        /// [Please do not use it] Bake Function
        /// </summary>
        /// <param name="textureID"></param>
        /// <param name="textureData"></param>
        public void Bake(int textureID, apTextureData textureData)
        {
            if (_linkedOptMeshes == null)
            {
                _linkedOptMeshes = new List <apOptMesh>();
            }

            _linkedOptMeshes.Clear();
            _texture = textureData._image;

            _textureID   = textureID;
            _srcUniqueID = textureData._uniqueID;            //
            _name        = textureData._name;
        }
        // Init
        //------------------------------------------------------------------
        public void Init(apEditor editor, apTextureData targetTextureData, object loadKey, FUNC_SELECT_TEXTUREASSET_RESULT funcResult)
        {
            _editor            = editor;
            _loadKey           = loadKey;
            _targetTextureData = targetTextureData;

            _funcResult = funcResult;

            _curSelectedTexture2D = null;

            _isSearched       = false;
            _strSearchKeyword = "";
            RefreshTextureAssets();
        }
Beispiel #8
0
            public ExtraDummyValue(apModifiedMesh.ExtraValue srcValue)
            {
                _isDepthChanged = srcValue._isDepthChanged;
                _deltaDepth     = srcValue._deltaDepth;

                _isTextureChanged  = srcValue._isTextureChanged;
                _linkedTextureData = srcValue._linkedTextureData;

                _textureDataID = srcValue._textureDataID;

                _weightCutout          = srcValue._weightCutout;
                _weightCutout_AnimPrev = srcValue._weightCutout_AnimPrev;
                _weightCutout_AnimNext = srcValue._weightCutout_AnimNext;
            }
Beispiel #9
0
        /// <summary>
        /// 현재 상태에 대한 Matrix 들을 계산하고 렌더링 준비를 한다.
        /// 이건 실시간으로 호출 될 수 있으므로 성능이 매우 중요하다.
        /// </summary>
        /// <param name="isMatrixCalculateForce">Matrix를 강제로 넣어야 한다. 초기화에 가까운 Force 옵션일때만 true 값을 넣자</param>
        //public void Update_Pre(float tDelta, bool isMatrixCalculateForce, apMeshGroup.FUNC_IS_FORCE_UPDATE funcForceUpdate)
        public void Update_Pre(float tDelta)
        {
            if (_calculatedStack != null)
            {
                //강제로 CalculateStack의 Hash를 업데이트해야하는지 결정한다.
                //bool isForceUpdateHash = isMatrixCalculateForce;
                //if(!isForceUpdateHash && funcForceUpdate != null)
                //{
                //	isForceUpdateHash = funcForceUpdate(this);
                //}

                //_calculatedStack.Calculate_Pre(tDelta, isForceUpdateHash);
                _calculatedStack.Calculate_Pre(tDelta);
            }


            apRenderUnit childRenderUnit = null;


            //_curMatrixToWorld를 처리한다.
            //1-1 Group Node일때
            if (_unitType == UNIT_TYPE.GroupNode)
            {
                if (_meshGroupTransform != null)
                {
                    //_meshGroupTransform._matrix.MakeMatrix();

                    //_matrixToParent = _meshGroupTransform._matrix.MtrxToSpace;

                    //------------------------------------------------
                    //[TODO] : Calculate Mesh Modifier를 넣어주자
                    if (_calculatedStack.MeshWorldMatrixWrap != null)
                    {
                        _meshGroupTransform.SetModifiedTransform(_calculatedStack.MeshWorldMatrixWrap);
                    }
                    //------------------------------------------------


                    //기존
                    //Parent의 계산된 Matrix를 중첩해주자
                    if (_parentRenderUnit != null)
                    {
                        if (_parentRenderUnit.WorldMatrixWrap != null)
                        {
                            //_meshGroupTransform.AddWorldMatrix_Parent(_parentRenderUnit.WorldMatrixOfNodeWrap);
                            _meshGroupTransform.AddWorldMatrix_Parent(_parentRenderUnit.WorldMatrixWrap);
                        }
                    }

                    #region [미사용 코드]
                    //신규
                    //Parent가 아닌 Child를 중첩해주자
                    //if (_childRenderUnits.Count > 0)
                    //{
                    //	//apRenderUnit childRenderUnit = null;
                    //	for (int i = 0; i < _childRenderUnits.Count; i++)
                    //	{
                    //		childRenderUnit = _childRenderUnits[i];
                    //		if(childRenderUnit._unitType == UNIT_TYPE.GroupNode)
                    //		{
                    //			if(childRenderUnit._meshGroupTransform != null)
                    //			{
                    //				childRenderUnit._meshGroupTransform.AddWorldMatrix_Parent(WorldMatrixOfNodeWrap);
                    //			}
                    //		}
                    //		else if(childRenderUnit._unitType == UNIT_TYPE.Mesh)
                    //		{
                    //			if(childRenderUnit._meshTransform != null)
                    //			{
                    //				childRenderUnit._meshTransform.AddWorldMatrix_Parent(WorldMatrixOfNodeWrap);
                    //			}
                    //		}
                    //	}
                    //}
                    #endregion


                    _meshGroupTransform.MakeTransformMatrix();
                }
                else
                {
                    //Root인 경우는 Mesh Group Transform이 없다.
                    //Root의 Local이 곧 World 이므로
                    //_matrixToParent = apMatrix3x3.identity;
                    //Root는 움직임이 없다. 외부에서 컨트롤하시길
                    ////>>>> 아니다 이놈아!
                    //if (_calculatedStack.MeshWorldMatrixWrap != null)
                    //{
                    //	_meshGroupTransform.SetModifiedTransform(_calculatedStack.MeshWorldMatrixWrap);
                    //}

                    //_meshGroupTransform.MakeTransformMatrix();
                }
            }
            //1-2 Mesh Node 일때
            else            //if (_unitType == UNIT_TYPE.Mesh)
            {
                //--------------------------------------------------
                if (_calculatedStack.MeshWorldMatrixWrap != null)
                {
                    //_meshTransform.SetModifiedTransform(_calculatedStack.MeshWorldMatrixWrap, _calculatedStack.CalculateLog_3_MeshTransform);
                    _meshTransform.SetModifiedTransform(_calculatedStack.MeshWorldMatrixWrap);
                }
                //--------------------------------------------------

                //기존
                //Parent의 계산된 Matrix를 중첩해주자
                if (_parentRenderUnit != null)
                {
                    if (_parentRenderUnit.WorldMatrixWrap != null)
                    {
                        _meshTransform.AddWorldMatrix_Parent(_parentRenderUnit.WorldMatrixWrap, _parentRenderUnit.WorldMatrixWrapWithoutModified);
                    }
                }

                _meshTransform.MakeTransformMatrix();
                //신규
                //부모 MeshGroupTransform의 RenderUnit이 알아서 해줄 것이다.
            }


            //색상도 만들어주자
            if (_calculatedStack.IsAnyColorCalculated)
            {
                _meshColor2X = _calculatedStack.MeshColor;
                _isVisible   = _calculatedStack.IsMeshVisible;
            }
            else
            {
                //만약 계산된게 없다면 Default 값을 사용한다.
                if (_unitType == UNIT_TYPE.GroupNode)
                {
                    if (_meshGroupTransform != null)
                    {
                        _meshColor2X = _meshGroupTransform._meshColor2X_Default;
                        _isVisible   = _meshGroupTransform._isVisible_Default;
                    }
                    else
                    {
                        _meshColor2X = _calculatedStack.MeshColor;
                        _isVisible   = _calculatedStack.IsMeshVisible;
                    }
                }
                else
                {
                    if (_meshTransform != null)
                    {
                        _meshColor2X = _meshTransform._meshColor2X_Default;
                        _isVisible   = _meshTransform._isVisible_Default;
                    }
                    else
                    {
                        _meshColor2X = _calculatedStack.MeshColor;
                        _isVisible   = _calculatedStack.IsMeshVisible;
                    }
                }
            }

            //추가 11.30 : Extra Option
            if (_calculatedStack.IsExtraDepthChanged)
            {
                _isExtraDepthChanged = true;
                _extraDeltaDepth     = _calculatedStack.ExtraDeltaDepth;

                //Debug.Log("Depth Event Occurred : " + Name);
                if (_func_ExtraDepthChanged != null)
                {
                    _func_ExtraDepthChanged(this, _extraDeltaDepth);
                }
                //else
                //{
                //	//Debug.LogError("No Event");
                //}
            }
            if (_calculatedStack.IsExtraTextureChanged)
            {
                _isExtraTextureChanged = true;
                _extraTextureData      = _calculatedStack.ExtraTextureData;
            }



            //에디터 전용
            //작업용 임시 Visible을 적용하자
            _isVisibleCalculated = _isVisible;
            if (_isVisibleCalculated && _isVisibleWorkToggle_Show2Hide)
            {
                _isVisible = false;                //<<강제로 Hide로 만든다.
            }
            else if (!_isVisibleCalculated && _isVisibleWorkToggle_Hide2Show)
            {
                _isVisible = true;                //<<강제로 Show로 만든다.
                if (_meshColor2X.a <= 0.0001f)
                {
                    _meshColor2X.a = 1.0f;
                }
            }

            _isVisible_WithoutParent = _isVisible;

            if (!_isVisible)
            {
                _meshColor2X.a = 0.0f;
            }

            if (_parentRenderUnit != null)
            {
                //2X 방식의 Add
                _meshColor2X.r  = Mathf.Clamp01(((float)(_meshColor2X.r) - 0.5f) + ((float)(_parentRenderUnit._meshColor2X.r) - 0.5f) + 0.5f);
                _meshColor2X.g  = Mathf.Clamp01(((float)(_meshColor2X.g) - 0.5f) + ((float)(_parentRenderUnit._meshColor2X.g) - 0.5f) + 0.5f);
                _meshColor2X.b  = Mathf.Clamp01(((float)(_meshColor2X.b) - 0.5f) + ((float)(_parentRenderUnit._meshColor2X.b) - 0.5f) + 0.5f);
                _meshColor2X.a *= _parentRenderUnit._meshColor2X.a;
            }

            //Alpha가 너무 작다면 => 아예 렌더링을 하지 않도록 제어 / 또는 Visible이 아닐때
            if (_meshColor2X.a < VISIBLE_ALPHA
                //|| !_calculatedStack.IsMeshVisible
                )
            {
                _isVisible     = false;
                _meshColor2X.a = 0.0f;
            }



            #region [미사용 코드]
            //이걸 누적해야함
            //if(_parentRenderUnit != null)
            //{
            //	//_matrixToWorld = _parentRenderUnit._matrixToWorld * _matrixToParent;

            //}
            //else
            //{
            //	//_matrixToWorld = _matrixToParent;
            //}
            ////_matrixWorldToVert = (_matrixToWorld * _matrixVertToLocal).inverse;
            #endregion

            #region [미사용 코드]
            ////Child까지 계산한 이후 Vertex를 계산해줘야 한다.
            //if(_unitType == UNIT_TYPE.Mesh)
            //{
            //	bool isVertexLocal = _calculatedStack.IsVertexLocal;
            //	bool isVertexWorld = _calculatedStack.IsVertexWorld;

            //	apRenderVertex rVert = null;
            //	for (int i = 0; i < _renderVerts.Count; i++)
            //	{
            //		rVert = _renderVerts[i];

            //		//단계별로 처리하자
            //		//1) Pivot 위치 적용
            //		rVert.SetMatrix_1_Static_Vert2Mesh(_meshTransform._mesh.Matrix_VertToLocal);

            //		if (isVertexLocal)
            //		{
            //			//Calculate - Vertex Local Morph (Vec2)
            //			rVert.SetMatrix_2_Calculate_VertLocal(_calculatedStack.GetVertexLocalPos(i));
            //		}

            //		rVert.SetMatrix_3_Transform_Mesh(WorldMatrixOfNode);

            //		if (isVertexWorld)
            //		{
            //			//Calculate - Vertex World Morph (Vec2)
            //			rVert.SetMatrix_4_Calculate_VertWorld(_calculatedStack.GetVertexWorldPos(i));
            //		}
            //		rVert.Calculate();
            //	}
            //}

            ////Child Render Unit도 계산한다.
            //if(_childRenderUnits.Count == 0)
            //{
            //	return;
            //}
            #endregion


            for (int i = 0; i < _childRenderUnits.Count; i++)
            {
                childRenderUnit = _childRenderUnits[i];

                //childRenderUnit.Update_Pre(tDelta, isMatrixCalculateForce, funcForceUpdate);
                childRenderUnit.Update_Pre(tDelta);
            }
        }
Beispiel #10
0
        // Calculate
        //---------------------------------------------------------------------
        public void ReadyToUpdate()
        {
            //if(_unitType != UNIT_TYPE.Mesh)
            //{
            //	return;
            //}

            _meshColor2X             = new Color(0.5f, 0.5f, 0.5f, 1.0f);
            _isVisible               = true;
            _isVisibleCalculated     = true;
            _isVisible_WithoutParent = true;

            //추가 11.30 : Extra Option
            _isExtraDepthChanged   = false;
            _extraDeltaDepth       = 0;
            _isExtraTextureChanged = false;
            _extraTextureData      = null;


            if (_unitType == UNIT_TYPE.Mesh)
            {
                _meshTransform.ReadyToCalculate();

                if (_isRenderVertsInit && _renderVerts.Count > 0)
                {
                    //return;
                }
                else
                {
                    _renderVerts.Clear();

                    if (_meshTransform != null)
                    {
                        if (_meshTransform._mesh != null)
                        {
                            List <apVertex> verts = _meshTransform._mesh._vertexData;
                            for (int i = 0; i < verts.Count; i++)
                            {
                                _renderVerts.Add(new apRenderVertex(this, _meshGroup, _meshTransform._mesh, verts[i]));
                            }
                        }

                        _isRenderVertsInit = true;
                    }
                }
            }
            else
            {
                if (_meshGroupTransform != null)
                {
                    _meshGroupTransform.ReadyToCalculate();
                }
            }

            if (_calculatedStack != null)
            {
                _calculatedStack.ReadyToCalculate();
            }


            if (_childRenderUnits.Count == 0)
            {
                return;
            }

            apRenderUnit childRenderUnit = null;

            for (int i = 0; i < _childRenderUnits.Count; i++)
            {
                childRenderUnit = _childRenderUnits[i];
                childRenderUnit.ReadyToUpdate();
            }
        }
Beispiel #11
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);
        }
Beispiel #12
0
 public void SetImage(apTextureData image, int regOrder)
 {
     SetData(OBJECT_TYPE.Image, image._uniqueID, regOrder);
     _linked_Image = image;
 }
Beispiel #13
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]);
            }
        }
Beispiel #14
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);
                }
            }
        }
        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);
            }
        }
Beispiel #16
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);
        }
        // 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]);
            }
        }
Beispiel #18
0
        private void DrawTextureUnit(apTextureData textureData, int width, int height)
        {
            int btnHeight       = 25;
            int imageSlotHeight = height - (btnHeight + 2);

            float baseAspectRatio = (float)width / (float)imageSlotHeight;

            EditorGUILayout.BeginVertical(GUILayout.Width(width), GUILayout.Height(imageSlotHeight));
            if (textureData._image == null)
            {
                GUIStyle guiStyle_Box = new GUIStyle(GUI.skin.box);
                guiStyle_Box.alignment        = TextAnchor.MiddleCenter;
                guiStyle_Box.normal.textColor = apEditorUtil.BoxTextColor;

                GUILayout.Box("Empty Image", guiStyle_Box, GUILayout.Width(width), GUILayout.Height(imageSlotHeight));
            }
            else
            {
                int imgWidth = textureData._width;
                if (imgWidth <= 0)
                {
                    imgWidth = 1;
                }

                int imgHeight = textureData._height;
                if (imgHeight <= 0)
                {
                    imgHeight = 1;
                }

                float aspectRatio = (float)imgWidth / (float)imgHeight;

                //가로를 채울 것인가, 세로를 채울 것인가
                if (aspectRatio > baseAspectRatio)
                {
                    //비율상 가로가 더 길다.
                    //가로에 맞추고 세로를 줄이자
                    imgWidth  = width;
                    imgHeight = (int)((float)imgWidth / aspectRatio);
                }
                else
                {
                    //비율상 세로가 더 길다.
                    //세로에 맞추고 가로를 줄이다.
                    imgHeight = imageSlotHeight;
                    imgWidth  = (int)((float)imageSlotHeight * aspectRatio);
                }
                int margin = (imageSlotHeight - imgHeight) / 2;
                if (margin > 0)
                {
                    //GUILayout.Space(margin);
                }
                GUIStyle guiStyle_Img = new GUIStyle(GUI.skin.box);
                guiStyle_Img.alignment = TextAnchor.MiddleCenter;

                Color prevColor = GUI.backgroundColor;
                Color boxColor  = prevColor;
                if (_curSelectedTextureData == textureData)
                {
                    boxColor.r = prevColor.r * 0.8f;
                    boxColor.g = prevColor.g * 0.8f;
                    boxColor.b = prevColor.b * 1.2f;
                }

                GUI.backgroundColor = boxColor;

                //if(GUILayout.Button(new GUIContent(textureData._image), guiStyle_Img, GUILayout.Width(imgWidth), GUILayout.Height(imgHeight)))
                if (GUILayout.Button(new GUIContent(textureData._image), guiStyle_Img, GUILayout.Width(width), GUILayout.Height(imageSlotHeight)))
                {
                    _curSelectedTextureData = textureData;
                }

                GUI.backgroundColor = prevColor;
            }
            EditorGUILayout.EndVertical();

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

            guiStyle_label.alignment = TextAnchor.MiddleCenter;

            EditorGUILayout.LabelField(textureData._name, guiStyle_label, GUILayout.Width(width), GUILayout.Height(20));

            //if(apEditorUtil.ToggledButton(textureData._name, textureData == _curSelectedTextureData, width, btnHeight))
            //{
            //	_curSelectedTextureData = textureData;
            //}
        }
Beispiel #19
0
        //Bake한 정보를 저장하자.
        public void SetPSDBakeData(string filePath, string fileNameOnly,
                                   apMeshGroup targetMeshGroup,
                                   List <apTextureData> addedTextureData,
                                   int atlasImageWidth, int atlasImageHeight,
                                   int PSDImageWidth, int PSDImageHeight,
                                   float PSDCenterOffsetDelta_X, float PSDCenterOffsetDelta_Y,
                                   string bakeDstFilePath, string bakeDstFileRelativePath,
                                   int bakeMaximumNumAtlas, int bakePadding, bool bakeBlurOption,
                                   int bakeScale100, int meshGroupScale100
                                   )
        {
            _filePath           = filePath;
            _fileNameOnly       = fileNameOnly;
            _lastBakedAssetName = fileNameOnly;
            //_isPSDFileExist = isPSDFileExist;

            if (targetMeshGroup != null)
            {
                _targetMeshGroupID = targetMeshGroup._uniqueID;
            }
            else
            {
                _targetMeshGroupID = -1;
                _targetTextureDataList.Clear();
            }
            //Debug.Log("SetPSDBakeData > Layer Clear");
            _layers.Clear();            //<<이건 다음 함수에서 순차적으로 설정

            _isLastBaked                      = true;
            _lastBaked_PSDImageWidth          = PSDImageWidth;
            _lastBaked_PSDImageHeight         = PSDImageHeight;
            _lastBaked_PSDCenterOffsetDelta_X = PSDCenterOffsetDelta_X;
            _lastBaked_PSDCenterOffsetDelta_Y = PSDCenterOffsetDelta_Y;
            _lastBaked_MeshGroupScaleX100     = meshGroupScale100;

            if (atlasImageWidth <= 256)
            {
                _bakeOption_Width = BAKE_SIZE.s256;
            }
            else if (atlasImageWidth <= 512)
            {
                _bakeOption_Width = BAKE_SIZE.s512;
            }
            else if (atlasImageWidth <= 1024)
            {
                _bakeOption_Width = BAKE_SIZE.s1024;
            }
            else if (atlasImageWidth <= 2048)
            {
                _bakeOption_Width = BAKE_SIZE.s2048;
            }
            else
            {
                _bakeOption_Width = BAKE_SIZE.s4096;
            }

            if (atlasImageHeight <= 256)
            {
                _bakeOption_Height = BAKE_SIZE.s256;
            }
            else if (atlasImageHeight <= 512)
            {
                _bakeOption_Height = BAKE_SIZE.s512;
            }
            else if (atlasImageHeight <= 1024)
            {
                _bakeOption_Height = BAKE_SIZE.s1024;
            }
            else if (atlasImageHeight <= 2048)
            {
                _bakeOption_Height = BAKE_SIZE.s2048;
            }
            else
            {
                _bakeOption_Height = BAKE_SIZE.s4096;
            }

            _bakeOption_DstFilePath         = bakeDstFilePath;
            _bakeOption_DstFileRelativePath = bakeDstFileRelativePath;
            _bakeOption_MaximumNumAtlas     = bakeMaximumNumAtlas;
            _bakeOption_Padding             = bakePadding;
            _bakeOption_BlurOption          = bakeBlurOption;
            _bakeScale100 = bakeScale100;

            if (addedTextureData != null && addedTextureData.Count > 0)
            {
                apTextureData curTexData = null;
                for (int i = 0; i < addedTextureData.Count; i++)
                {
                    curTexData = addedTextureData[i];

                    if (_targetTextureDataList.Exists(delegate(TextureDataSet a)
                    {
                        return(a._textureDataID == curTexData._uniqueID);
                    }))
                    {
                        //이미 존재한다면 패스
                        continue;
                    }
                    TextureDataSet newSet = new TextureDataSet();
                    newSet._textureDataID     = curTexData._uniqueID;
                    newSet._linkedTextureData = curTexData;
                    _targetTextureDataList.Add(newSet);
                }
            }
        }