示例#1
0
        private void OnGUI()
        {
            PumkinsBlendshapePreset preset = (PumkinsBlendshapePreset)CreatePresetPopupBase.preset;

            if (!preset)
            {
                AssignOrCreatePreset <PumkinsBlendshapePreset>(preset);
                return;
            }
            try
            {
                scroll = EditorGUILayout.BeginScrollView(scroll);
                {
                    EditorGUILayout.Space();

                    preset.name = EditorGUILayout.TextField(Strings.Presets.presetName, preset.name);

                    Helpers.DrawGUILine();

                    PumkinsAvatarTools.DrawAvatarSelectionWithButtonGUI(false, false);

                    Helpers.DrawGUILine();

                    DrawBlendshapePresetControls();

                    Helpers.DrawGUILine();

                    EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(preset.name) || !PumkinsAvatarTools.SelectedAvatar);
                    {
                        if (!editingExistingPreset)
                        {
                            _overwriteFile = GUILayout.Toggle(_overwriteFile, Strings.Presets.overwriteFile);
                            if (GUILayout.Button(Strings.Buttons.savePreset, Styles.BigButton))
                            {
                                EditorApplication.delayCall += () =>
                                {
                                    preset.SavePreset(_overwriteFile);
                                    Close();
                                };
                            }
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndScrollView();
                CreatePresetPopupBase.preset = preset;
            }
            catch
            {
                if (this)
                {
                    Close();
                }
            }
        }
        public void OnGUI()
        {
            //deltaTime = Time.time - lastTime;
            //lastTime = Time.time;
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField(Strings.PoseEditor.title, Styles.Label_mainTitle);

                if (GUILayout.Button(Icons.Settings, Styles.IconButton))
                {
                    _openedSettings = !_openedSettings;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField(Strings.PoseEditor.version);
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            {
                PumkinsAvatarTools.DrawAvatarSelectionWithButtonGUI();
            }

            //if(GUILayout.Button("Dump muscle names"))
            //{
            //    string s = "";
            //    foreach(string m in HumanTrait.MuscleName)
            //    {
            //        s += "\"" + m + "\",\n";
            //    }
            //    Debug.Log(s);
            //}

            Helpers.DrawGUILine();

            if (_openedSettings)
            {
                DrawSettingsGUI();
            }
            else
            {
                DrawMainGUI();
            }
        }
        void OnGUI()
        {
            try
            {
                PumkinsCameraPreset newPreset = (PumkinsCameraPreset)preset;
                if (!newPreset) //Not sure I like this part
                {
                    newPreset = (PumkinsCameraPreset)AssignOrCreatePreset <PumkinsCameraPreset>(null);
                    preset    = newPreset;
                }

                Rect r = GUILayoutUtility.GetAspectRect(1.3f);
                EditorGUI.DrawTextureTransparent(r, PumkinsAvatarTools.SelectedCamRT, ScaleMode.ScaleToFit);

                scroll = EditorGUILayout.BeginScrollView(scroll);
                {
                    if (newPreset)
                    {
                        newPreset.name = EditorGUILayout.TextField(Strings.Presets.presetName, newPreset.name);

                        EditorGUILayout.Space();

                        PumkinsAvatarTools.DrawAvatarSelectionWithButtonGUI(false, false);

                        Helpers.DrawGUILine();

                        PumkinsAvatarTools.SelectedCamera = (Camera)EditorGUILayout.ObjectField(Strings.Presets.camera, PumkinsAvatarTools.SelectedCamera, typeof(Camera), true);

                        EditorGUILayout.Space();

                        newPreset.offsetMode = (PumkinsCameraPreset.CameraOffsetMode)EditorGUILayout.EnumPopup(Strings.Presets.offsetMode, newPreset.offsetMode);
                        if (newPreset.offsetMode == PumkinsCameraPreset.CameraOffsetMode.Transform)
                        {
                            EditorGUI.BeginDisabledGroup(!PumkinsAvatarTools.SelectedAvatar);
                            {
                                referenceTransform = EditorGUILayout.ObjectField(Strings.Presets.transform, referenceTransform, typeof(Transform), true) as Transform;
                                if (referenceTransform && !referenceTransform.IsChildOf(PumkinsAvatarTools.SelectedAvatar.transform))
                                {
                                    PumkinsAvatarTools.Log(Strings.Presets.transformDoesntBelongToAvatar, LogType.Warning, referenceTransform.name, PumkinsAvatarTools.SelectedAvatar.name);
                                    referenceTransform = null;
                                }
                            }
                        }
                        EditorGUILayout.Space();

                        Helpers.DrawGUILine();

                        PumkinsAvatarTools.Instance.DrawOverlayGUI();

                        Helpers.DrawGUILine();

                        PumkinsAvatarTools.Instance.DrawBackgroundGUI();

                        Helpers.DrawGUILine();

                        PumkinsAvatarTools.Instance.DrawCameraControlButtons();
                    }
                    EditorGUILayout.EndScrollView();

                    Helpers.DrawGUILine();

                    if (!editingExistingPreset)
                    {
                        EditorGUI.BeginDisabledGroup(!PumkinsAvatarTools.SelectedCamera || string.IsNullOrEmpty(newPreset.name) || !PumkinsAvatarTools.SelectedAvatar);
                        {
                            _overwriteFile = GUILayout.Toggle(_overwriteFile, Strings.Presets.overwriteFile);
                            EditorGUI.BeginDisabledGroup(newPreset.offsetMode == PumkinsCameraPreset.CameraOffsetMode.Transform && referenceTransform == null);
                            {
                                if (GUILayout.Button(Strings.Buttons.savePreset, Styles.BigButton))
                                {
#if (VRC_SDK_VRCSDK3 || VRC_SDK_VRCSDK2) && !UDON
                                    if (newPreset.offsetMode == PumkinsCameraPreset.CameraOffsetMode.Viewpoint && (Avatar.GetComponent <VRC_AvatarDescriptor>() == null))
                                    {
                                        PumkinsAvatarTools.Log(Strings.Log.descriptorIsMissingCantGetViewpoint, LogType.Warning);
                                    }
                                    else
#endif
                                    if (newPreset.offsetMode == PumkinsCameraPreset.CameraOffsetMode.Transform)
                                    {
                                        EditorApplication.delayCall += () =>
                                        {
                                            newPreset.SavePreset(referenceTransform.gameObject, PumkinsAvatarTools.SelectedCamera, _overwriteFile);
                                            Close();
                                        };
                                    }
                                    else
                                    {
                                        EditorApplication.delayCall += () =>
                                        {
                                            newPreset.SavePreset(PumkinsAvatarTools.SelectedAvatar, PumkinsAvatarTools.SelectedCamera, _overwriteFile);
                                            Close();
                                        };
                                    }
                                }
                                EditorGUILayout.Space();
                            }
                            EditorGUI.EndDisabledGroup();
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                }
            }
            catch
            {
                if (this)
                {
                    Close();
                }
            }
        }
        private void OnGUI()
        {
            PumkinsPosePreset preset = (PumkinsPosePreset)CreatePresetPopupBase.preset;

            if (!preset)
            {
                AssignOrCreatePreset <PumkinsPosePreset>(null);
                return;
            }

            try
            {
                scroll = EditorGUILayout.BeginScrollView(scroll);
                {
                    EditorGUILayout.Space();

                    preset.name = EditorGUILayout.TextField(Strings.Presets.presetName, preset.name);

                    Helpers.DrawGUILine();

                    PumkinsAvatarTools.DrawAvatarSelectionWithButtonGUI(false, false);

                    Helpers.DrawGUILine();

                    preset.presetMode = (PumkinsPosePreset.PosePresetMode)EditorGUILayout.EnumPopup(Strings.Presets.poseMode, preset.presetMode);

                    Helpers.DrawGUILine();

                    if (GUILayout.Button(Strings.Buttons.openPoseEditor, Styles.BigButton))
                    {
                        PumkinsMuscleEditor.ShowWindow();
                    }

                    Helpers.DrawGUILine();

                    EditorGUI.BeginDisabledGroup(!PumkinsAvatarTools.SelectedAvatar || !preset || string.IsNullOrEmpty(preset.name));
                    {
                        if (!editingExistingPreset)
                        {
                            _overwriteFile = GUILayout.Toggle(_overwriteFile, Strings.Presets.overwriteFile);
                            if (GUILayout.Button(Strings.Buttons.savePreset, Styles.BigButton))
                            {
                                preset.SetupPreset(preset.name, PumkinsAvatarTools.SelectedAvatar, preset.presetMode);
                                if (preset)
                                {
                                    EditorApplication.delayCall += () =>
                                    {
                                        preset.SavePreset(_overwriteFile);
                                        Close();
                                    };
                                }
                            }
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndScrollView();
                CreatePresetPopupBase.preset = preset;
            }
            catch
            {
                if (this)
                {
                    Close();
                }
            }
        }