コード例 #1
0
        void RefreshFromSpriteFile()
        {
            if (EditorUtility.DisplayDialogComplex("RefreshFromSpriteFile",
                                                   "スプライトからCharaCellデータを再生しますか?",
                                                   "OK", "キャンセル", "") == 0)
            {
                Debug.Log("RefreshFromSpriteFile");
                var newCharCells = new CharaCellObject();

                // 現在のスプライトにあるものを抽出、ない場合は新たに作成
                for (int i = 0; i < m_bodySprites.Length; ++i)
                {
                    string    id   = CharaCell.ReplaceHyphen(m_bodySprites[i].name);
                    CharaCell item = m_charCells.param.FirstOrDefault(x => x.ID == id);
                    if (item == null)
                    {
                        item    = new CharaCell();
                        item.ID = id;
                    }

                    newCharCells.param.Add(item);
                }

                m_charCells = newCharCells;

                UpdateCharaCellDict();

                AssetDatabase.Refresh();
            }
        }
コード例 #2
0
        // 画像一覧をボタン選択出来る形にして出力
        void DrawImageParts()
        {
            m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition, GUI.skin.box);

            //if(imgDirectory != null)
            {
                float x = 0.0f;
                float y = 00.0f;
                //float size = 48;
                //float h = 50.0f;
                float maxW = TIPSIZE * 5;

                EditorGUILayout.BeginVertical();
                int  index = 0;
                bool isEnd = false;
                foreach (var sp in m_bodySprites)
                {
                    string     spname   = CharaCell.ReplaceHyphen(sp.name);
                    GUIContent contents = new GUIContent();
                    if (!m_charCellDict.ContainsKey(spname))
                    {
                        Debug.Log($"NotFound {spname}");
                        m_isLoadSprite = false;
                        return;
                    }

                    contents.text = spname
                                    + "\n No:" + m_charCellDict[spname].faceNo.ToString()
                                    + " X:" + m_charCellDict[spname].faceX.ToString()
                                    + " Y:" + m_charCellDict[spname].faceY.ToString();

                    if ((m_charCellDict[spname].faceNo == 0) && (m_charCellDict[spname].faceX == 0) && (m_charCellDict[spname].faceY == 0))
                    {
                        contents.text += " *AllZero*";
                    }

                    //GUILayout.FlexibleSpace();
                    if (m_selectedSprite == index)
                    {
                        GUI.color = new Color(1f, 0.5f, 1f, 1f);
                    }
                    if (GUILayout.Button(contents, GUILayout.MaxWidth(TIPSIZE * 5), GUILayout.Height(TIPSIZE), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)))
                    {
                        m_selectedSprite = index;
                        RefreshEditorWindow();
                    }
                    if (m_selectedSprite == index)
                    {
                        GUI.color = new Color(1f, 1f, 1f, 1f);
                    }

                    Rect lastRect = GUILayoutUtility.GetLastRect();

                    lastRect.width  = TIPSIZE;
                    lastRect.height = TIPSIZE;
                    GUI.DrawTextureWithTexCoords(lastRect, sp.texture, GetSpriteNormalRect(sp));
                    y += TIPSIZE;
                    index++;
                }

                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndScrollView();
        }