private void OnSelectedPoseChanged(ChangeEvent <UnityEngine.Object> evt) { if (Application.isPlaying) { return; } if (evt.newValue != null) { var newPose = evt.newValue as HVRHandPose; ThisHand.Pose(newPose.GetPose(IsLeft)); UpdatePreview(SP_DoPreview.boolValue, false); } else { PreviewToggle.SetValueWithoutNotify(false); if (PreviewInstance) { DestroyImmediate(PreviewInstance); } _root.schedule.Execute(() => { TrySetToDefault(); }); } }
public override VisualElement CreateInspectorGUI() { _root = new VisualElement(); var defaultUI = new VisualElement(); var iterator = serializedObject.GetIterator(); if (iterator.NextVisible(true)) { do { var propertyField = new PropertyField(iterator.Copy()) { name = "PropertyField:" + iterator.propertyPath }; if (iterator.propertyPath == "m_Script" && serializedObject.targetObject != null) { propertyField.SetEnabled(value: false); } defaultUI.Add(propertyField); }while (iterator.NextVisible(false)); } var folder = new Foldout(); folder.Add(defaultUI); folder.text = "Default Inspector"; _root.Add(folder); _editorContainer = new VisualElement(); var editorTree = UnityEngine.Resources.Load <VisualTreeAsset>("HVRHandPoseEditor"); editorTree.CloneTree(_editorContainer); _editorContainer.Q <ObjectField>("SelectedPose").objectType = typeof(HVRHandPose); _root.Add(_editorContainer); PropertyField_IsLeft = _root.Q <PropertyField>("PropertyField:IsLeft"); PropertyField_IsLeft.RegisterCallback(new EventCallback <ChangeEvent <bool> >(OnIsLeftChanged)); HandContainer = _editorContainer.Q <VisualElement>("HandContainer"); PreviewToggle = HandContainer.Q <Toggle>("Preview"); PreviewToggle.BindProperty(SP_DoPreview); PreviewToggle.RegisterValueChangedCallback(OnPreviewChanged); UpdatePreview(SP_DoPreview.boolValue, true); SetupSelectedPose(); SetupNewButton(); SetupSaveAsButton(); SetupSaveButton(); //if (SP_SelectedPose.objectReferenceValue != null) //{ // var currentPose = SP_SelectedPose.objectReferenceValue as VRHandPose; // ThisHand.Pose(currentPose.GetPose(IsLeft)); //} return(_root); }