From ce8c09c89d0bf9ec906a4eb62a099d0618a7cde2 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 27 Dec 2018 15:32:58 +0900 Subject: [PATCH] Added VRMFirstPersonEditor #66 --- .../Editor/VRMFirstPersonEditor.cs | 28 +++++++++++++++++++ .../Editor/VRMFirstPersonEditor.cs.meta | 12 ++++++++ 2 files changed, 40 insertions(+) create mode 100644 Scripts/FirstPerson/Editor/VRMFirstPersonEditor.cs create mode 100644 Scripts/FirstPerson/Editor/VRMFirstPersonEditor.cs.meta diff --git a/Scripts/FirstPerson/Editor/VRMFirstPersonEditor.cs b/Scripts/FirstPerson/Editor/VRMFirstPersonEditor.cs new file mode 100644 index 0000000000..1e6f49d3f5 --- /dev/null +++ b/Scripts/FirstPerson/Editor/VRMFirstPersonEditor.cs @@ -0,0 +1,28 @@ +using UnityEditor; + + +namespace VRM +{ + [CustomEditor(typeof(VRMFirstPerson))] + class VRMFirstPersonEditor : Editor + { + void OnSceneGUI() + { + var component = target as VRMFirstPerson; + + var head = component.FirstPersonBone; + if (head == null) + { + return; + } + + + var worldOffset = head.localToWorldMatrix.MultiplyPoint(component.FirstPersonOffset); + worldOffset = Handles.PositionHandle(worldOffset, head.rotation); + + Handles.Label(worldOffset, "FirstPersonOffset"); + + component.FirstPersonOffset = head.worldToLocalMatrix.MultiplyPoint(worldOffset); + } + } +} diff --git a/Scripts/FirstPerson/Editor/VRMFirstPersonEditor.cs.meta b/Scripts/FirstPerson/Editor/VRMFirstPersonEditor.cs.meta new file mode 100644 index 0000000000..3af9542c14 --- /dev/null +++ b/Scripts/FirstPerson/Editor/VRMFirstPersonEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e68be7adce7f09d4287af62a2bac63d7 +timeCreated: 1545891764 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: