Пример #1
0
        private void OnEnable()
        {
            edittingAvatar = new VRCAvatar();

            editorFolderPath = Path.GetDirectoryName(
                AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(this)));
            editorFolderPath = editorFolderPath.Substring(0, editorFolderPath.LastIndexOf(Path.DirectorySeparatorChar) + 1);

            saveFolder = "Assets/";


            licenseText = FileUtility.GetFileTexts(editorFolderPath + LICENSE_FILE_NAME);
            readmeText  = FileUtility.GetFileTexts(editorFolderPath + README_FILE_NAME);
            usingSoftwareLicenseText = FileUtility.GetFileTexts(editorFolderPath + USING_SOFTWARE_FILE_NAME);

            avatarMonitorGUI = ScriptableObject.CreateInstance <AvatarMonitorGUI>();
            animationsGUI    = ScriptableObject.CreateInstance <AnimationsGUI>();
            avatarInfoGUI    = ScriptableObject.CreateInstance <AvatarInfoGUI>();
            faceEmotionGUI   = ScriptableObject.CreateInstance <FaceEmotionGUI>();
            probeAnchorGUI   = ScriptableObject.CreateInstance <ProbeAnchorGUI>();
            meshBoundsGUI    = ScriptableObject.CreateInstance <MeshBoundsGUI>();
            shaderGUI        = ScriptableObject.CreateInstance <ShaderGUI>();

            toolGUIs.Add(ToolFunc.AvatarInfo, avatarInfoGUI);
            toolGUIs.Add(ToolFunc.FaceEmotion, faceEmotionGUI);
            toolGUIs.Add(ToolFunc.ProbeAnchor, probeAnchorGUI);
            toolGUIs.Add(ToolFunc.Bounds, meshBoundsGUI);
            toolGUIs.Add(ToolFunc.Shader, shaderGUI);

            avatarMonitorGUI.Initialize(CurrentTool);
            animationsGUI.Initialize(edittingAvatar, originalAvatar, saveFolder, this, faceEmotionGUI);
            avatarInfoGUI.Initialize(originalAvatar, edittingAvatar, avatarMonitorGUI);
            probeAnchorGUI.Initialize(originalAvatar);

            selectedToolGUI = avatarInfoGUI;
            CurrentTool     = ToolFunc.AvatarInfo;

            (layoutType, language) = EditorSetting.instance.LoadSettingDataFromScriptableObject(
                editorFolderPath, language,
                avatarMonitorGUI, faceEmotionGUI);

            // Windowを開いたときにオブジェクトが選択されていればそれをアバターとして設定する
            if (Selection.gameObjects.Length == 1)
            {
                var selectionTransform = Selection.gameObjects.Single().transform;
                while (selectionTransform != null)
                {
                    targetAvatarDescriptor = selectionTransform.GetComponent <VRC_AvatarDescriptor>();
                    if (targetAvatarDescriptor != null)
                    {
                        OnChangedAvatar();
                        break;
                    }
                    selectionTransform = selectionTransform.parent;
                }
            }

            SceneView.onSceneGUIDelegate += OnSceneGUI;
        }
Пример #2
0
        private void OnChangedAvatar()
        {
            edittingAvatar = avatarMonitorGUI.SetAvatarPreview(targetAvatarDescriptor);
            originalAvatar = new VRCAvatar(targetAvatarDescriptor);
            EditorSetting.instance.ApplySettingsToEditorGUI(edittingAvatar, faceEmotionGUI);

            var targetAvatarObj = targetAvatarDescriptor.gameObject;

            targetAvatarObj.SetActive(true);

            avatarMonitorGUI.MoveAvatarCam(false, false);
            animationsGUI.Initialize(edittingAvatar, originalAvatar, saveFolder, this, faceEmotionGUI);
            avatarInfoGUI.Initialize(originalAvatar, edittingAvatar, avatarMonitorGUI);
            meshBoundsGUI.Initialize(originalAvatar);
            probeAnchorGUI.Initialize(originalAvatar);

            CurrentTool = ToolFunc.AvatarInfo;
        }