/// <summary>
        /// アバターパーツ変更
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dir"></param>
        private void ChangeParts(int id, int dir)
        {
            //Debug.Log("id:" + id + " dir:" + dir);

            var group = avatarPartsGroupList[id];

            if (group.handle != 0)
            {
                avatar.DetachAvatarParts(group.handle);
                group.handle = 0;
            }

            var index = group.index + dir;
            int cnt   = group.partsPrefabList.Count;

            if (index < 0)
            {
                index += cnt;
            }
            else if (index >= cnt)
            {
                index -= cnt;
            }
            group.index = index;

            group.handle = avatar.AttachAvatarParts(group.partsPrefabList[index]);
        }
Example #2
0
 //=============================================================================================
 /// <summary>
 /// 破棄
 /// </summary>
 public void Dispose()
 {
     // 親から削除する
     if (parentAvatar != null)
     {
         parentAvatar.DetachAvatarParts(gameObject);
         parentAvatar = null;
     }
 }
        //=========================================================================================
        /// <summary>
        /// パーツ一覧表示
        /// </summary>
        private bool DrawPartsList()
        {
            MagicaAvatar scr    = target as MagicaAvatar;
            bool         change = false;

            EditorGUILayout.LabelField("Attach Parts", EditorStyles.boldLabel);

            // ドラッグ&ドロップ
            change = DrawPartsDragAndDropArea();

            // パーツ一覧
            MagicaAvatarParts removeParts = null;

            for (int i = 0; i < scr.Runtime.AvatarPartsCount; i++)
            {
                var parts = scr.Runtime.GetAvatarParts(i);
                if (parts)
                {
                    EditorGUILayout.BeginHorizontal(GUI.skin.box);
                    GUILayout.Space(30);
                    EditorGUILayout.HelpBox(parts.name, MessageType.None);
                    GUI.backgroundColor = Color.red;
                    if (GUILayout.Button("Remove"))
                    {
                        removeParts = parts;
                    }
                    GUI.backgroundColor = Color.white;
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            if (removeParts)
            {
                // パーツ削除
                scr.DetachAvatarParts(removeParts);
                change = true;
            }

            return(change);
        }