[1.0] bone selector(experimental) 【squash merge】 (#1228)

* 過去のBoneGizmoブランチから復旧

* mv

* mv

* remove _bonePoint

* mv Editor. BoneInfo, BoneSelector, BoneDrawer

* Undo, Hover

* fix Asset
This commit is contained in:
ousttrue
2021-09-17 14:10:25 +09:00
committed by GitHub
parent b639c63162
commit 48ed88c4ae
26 changed files with 1748 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 06042b0f878b192408eae7a784579410
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,276 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace UniGLTF
{
public class BoneInfo
{
private readonly Transform _head;
private readonly Transform _tail;
private readonly Vector3 _headLocalForward;
private readonly Vector3 _headLocalUp;
public HumanBodyBones HeadBone { get; private set; }
public HumanBodyBones TailBone { get; private set; }
public GameObject HeadObject { get { return _head.gameObject; } }
public BoneInfo(Transform head, Transform tail, HumanBodyBones headBone, HumanBodyBones tailBone)
{
_head = head;
_tail = tail;
_headLocalForward = (_head != null && _tail != null) ?
_head.InverseTransformPoint(_tail.position) :
new Vector3(0, 0, 0.1f);
_headLocalUp = CalculateLocalUpVector(_headLocalForward);
HeadBone = headBone;
TailBone = tailBone;
}
public BoneInfo(Transform head, Vector3 headLocalDirection, HumanBodyBones headBone)
{
_head = head;
_tail = null;
_headLocalForward = headLocalDirection;
_headLocalUp = CalculateLocalUpVector(_headLocalForward);
HeadBone = headBone;
}
public override string ToString()
{
return $"{_head}";
}
public Vector3 GetHeadPosition()
{
if (_head == null) return Vector3.zero;
return _head.position;
}
public Vector3 GetTailPosition()
{
if (_tail == null)
{
return _head.TransformPoint(_headLocalForward);
}
else
{
return _tail.position;
}
}
public Vector3 GetUpVector()
{
if (_head == null) return Vector3.zero;
return _head.TransformVector(_headLocalUp);
}
private static Vector3 CalculateLocalUpVector(Vector3 localForward)
{
var dotX = Mathf.Abs(Vector3.Dot(localForward, new Vector3(1, 0, 0)));
var dotY = Mathf.Abs(Vector3.Dot(localForward, new Vector3(0, 1, 0)));
var dotZ = Mathf.Abs(Vector3.Dot(localForward, new Vector3(0, 0, 1)));
if (dotX > dotY && dotX > dotZ)
{
return new Vector3(0, 1, 0);
}
if (dotY > dotX && dotY > dotZ)
{
return new Vector3(0, 0, 1);
}
else
{
return new Vector3(0, 1, 0);
}
}
#region Humanoid Bone info
private static readonly Dictionary<HumanBodyBones, Vector3> LeafBoneWithDirection =
new Dictionary<HumanBodyBones, Vector3>
{
{HumanBodyBones.Head, Vector3.zero},
{HumanBodyBones.LeftToes, Vector3.forward},
{HumanBodyBones.RightToes, Vector3.forward},
{HumanBodyBones.LeftEye, Vector3.forward},
{HumanBodyBones.RightEye, Vector3.forward},
{HumanBodyBones.Jaw, Vector3.forward},
{HumanBodyBones.LeftThumbDistal, Vector3.zero},
{HumanBodyBones.LeftIndexDistal, Vector3.zero},
{HumanBodyBones.LeftMiddleDistal, Vector3.zero},
{HumanBodyBones.LeftRingDistal, Vector3.zero},
{HumanBodyBones.LeftLittleDistal, Vector3.zero},
{HumanBodyBones.RightThumbDistal, Vector3.zero},
{HumanBodyBones.RightIndexDistal, Vector3.zero},
{HumanBodyBones.RightMiddleDistal, Vector3.zero},
{HumanBodyBones.RightRingDistal, Vector3.zero},
{HumanBodyBones.RightLittleDistal, Vector3.zero},
};
static HumanBodyBones[] _NotConnectedBones = new HumanBodyBones[]{
HumanBodyBones.LeftShoulder ,
HumanBodyBones.RightShoulder,
HumanBodyBones.LeftUpperLeg ,
HumanBodyBones.RightUpperLeg,
HumanBodyBones.LeftEye,
HumanBodyBones.RightEye,
HumanBodyBones.Jaw,
};
public static List<BoneInfo> GetHumanoidBones(Animator _animator)
{
List<BoneInfo> _bones = new List<BoneInfo>();
if (_animator == null || !_animator.isHuman)
{
throw new ArgumentException("not humanoid");
}
var validBones = ((HumanBodyBones[])Enum.GetValues(typeof(HumanBodyBones)))
.Where(x => x != HumanBodyBones.LastBone)
.ToArray();
var headSelectedBones = new HashSet<HumanBodyBones>();
foreach (var x in validBones)
{
var tailTf = _animator.GetBoneTransform(x);
if (tailTf == null) continue;
if (_NotConnectedBones.Contains(x))
{
// この組み合わせはHumanoidボーンではないので
continue;
}
var head = FindHeadBone(_animator, x);
if (!head.HasValue) continue;
var headTf = _animator.GetBoneTransform(head.Value);
if (headTf == null) continue;
_bones.Add(new BoneInfo(headTf, tailTf, head.Value, x));
headSelectedBones.Add(head.Value);
}
foreach (var kv in LeafBoneWithDirection)
{
var head = kv.Key;
var headTf = _animator.GetBoneTransform(head);
if (headTf == null) continue;
var parent = FindHeadBone(_animator, head);
var parentTf = parent.HasValue ? _animator.GetBoneTransform(parent.Value) : null;
if (kv.Value == Vector3.zero)
{
if (parentTf == null) continue;
var direction = headTf.InverseTransformPoint(parentTf.position);
_bones.Add(new BoneInfo(headTf, -direction, parent.Value));
}
else
{
var distance = 0.05f;
if (parentTf != null)
{
distance = Vector3.Distance(headTf.position, parentTf.position);
}
_bones.Add(new BoneInfo(headTf, kv.Value * distance, parent.Value));
}
}
return _bones;
}
private static HumanBodyBones? FindHeadBone(Animator _animator, HumanBodyBones tail)
{
var tailTransform = _animator.GetBoneTransform(tail);
if (tailTransform == null) return null;
HumanBodyBones? headCandidate = tail;
while (true)
{
headCandidate = GetParent(headCandidate.Value);
if (!headCandidate.HasValue)
{
// Root まで探しきった
return null;
}
var headCandidateTf = _animator.GetBoneTransform(headCandidate.Value);
if (headCandidateTf != null)
{
return headCandidate.Value;
}
}
}
private static HumanBodyBones? GetParent(HumanBodyBones bone)
{
switch (bone)
{
case HumanBodyBones.Hips: return null;
case HumanBodyBones.LeftUpperLeg: return HumanBodyBones.Hips;
case HumanBodyBones.RightUpperLeg: return HumanBodyBones.Hips;
case HumanBodyBones.LeftLowerLeg: return HumanBodyBones.LeftUpperLeg;
case HumanBodyBones.RightLowerLeg: return HumanBodyBones.RightUpperLeg;
case HumanBodyBones.LeftFoot: return HumanBodyBones.LeftLowerLeg;
case HumanBodyBones.RightFoot: return HumanBodyBones.RightLowerLeg;
case HumanBodyBones.Spine: return HumanBodyBones.Hips;
case HumanBodyBones.Chest: return HumanBodyBones.Spine;
case HumanBodyBones.UpperChest: return HumanBodyBones.Chest;
case HumanBodyBones.Neck: return HumanBodyBones.UpperChest;
case HumanBodyBones.Head: return HumanBodyBones.Neck;
case HumanBodyBones.LeftShoulder: return HumanBodyBones.UpperChest;
case HumanBodyBones.RightShoulder: return HumanBodyBones.UpperChest;
case HumanBodyBones.LeftUpperArm: return HumanBodyBones.LeftShoulder;
case HumanBodyBones.RightUpperArm: return HumanBodyBones.RightShoulder;
case HumanBodyBones.LeftLowerArm: return HumanBodyBones.LeftUpperArm;
case HumanBodyBones.RightLowerArm: return HumanBodyBones.RightUpperArm;
case HumanBodyBones.LeftHand: return HumanBodyBones.LeftLowerArm;
case HumanBodyBones.RightHand: return HumanBodyBones.RightLowerArm;
case HumanBodyBones.LeftToes: return HumanBodyBones.LeftFoot;
case HumanBodyBones.RightToes: return HumanBodyBones.RightFoot;
case HumanBodyBones.LeftEye: return HumanBodyBones.Head;
case HumanBodyBones.RightEye: return HumanBodyBones.Head;
case HumanBodyBones.Jaw: return HumanBodyBones.Head;
case HumanBodyBones.LeftThumbProximal: return HumanBodyBones.LeftHand;
case HumanBodyBones.LeftThumbIntermediate: return HumanBodyBones.LeftThumbProximal;
case HumanBodyBones.LeftThumbDistal: return HumanBodyBones.LeftThumbIntermediate;
case HumanBodyBones.LeftIndexProximal: return HumanBodyBones.LeftHand;
case HumanBodyBones.LeftIndexIntermediate: return HumanBodyBones.LeftIndexProximal;
case HumanBodyBones.LeftIndexDistal: return HumanBodyBones.LeftIndexIntermediate;
case HumanBodyBones.LeftMiddleProximal: return HumanBodyBones.LeftHand;
case HumanBodyBones.LeftMiddleIntermediate: return HumanBodyBones.LeftMiddleProximal;
case HumanBodyBones.LeftMiddleDistal: return HumanBodyBones.LeftMiddleIntermediate;
case HumanBodyBones.LeftRingProximal: return HumanBodyBones.LeftHand;
case HumanBodyBones.LeftRingIntermediate: return HumanBodyBones.LeftRingProximal;
case HumanBodyBones.LeftRingDistal: return HumanBodyBones.LeftRingIntermediate;
case HumanBodyBones.LeftLittleProximal: return HumanBodyBones.LeftHand;
case HumanBodyBones.LeftLittleIntermediate: return HumanBodyBones.LeftLittleProximal;
case HumanBodyBones.LeftLittleDistal: return HumanBodyBones.LeftLittleIntermediate;
case HumanBodyBones.RightThumbProximal: return HumanBodyBones.RightHand;
case HumanBodyBones.RightThumbIntermediate: return HumanBodyBones.RightThumbProximal;
case HumanBodyBones.RightThumbDistal: return HumanBodyBones.RightThumbIntermediate;
case HumanBodyBones.RightIndexProximal: return HumanBodyBones.RightHand;
case HumanBodyBones.RightIndexIntermediate: return HumanBodyBones.RightIndexProximal;
case HumanBodyBones.RightIndexDistal: return HumanBodyBones.RightIndexIntermediate;
case HumanBodyBones.RightMiddleProximal: return HumanBodyBones.RightHand;
case HumanBodyBones.RightMiddleIntermediate: return HumanBodyBones.RightMiddleProximal;
case HumanBodyBones.RightMiddleDistal: return HumanBodyBones.RightMiddleIntermediate;
case HumanBodyBones.RightRingProximal: return HumanBodyBones.RightHand;
case HumanBodyBones.RightRingIntermediate: return HumanBodyBones.RightRingProximal;
case HumanBodyBones.RightRingDistal: return HumanBodyBones.RightRingIntermediate;
case HumanBodyBones.RightLittleProximal: return HumanBodyBones.RightHand;
case HumanBodyBones.RightLittleIntermediate: return HumanBodyBones.RightLittleProximal;
case HumanBodyBones.RightLittleDistal: return HumanBodyBones.RightLittleIntermediate;
case HumanBodyBones.LastBone: return null;
default:
throw new ArgumentOutOfRangeException(nameof(bone), bone, null);
}
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 748babbafd77e0b478581a17cd015859
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,188 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
namespace UniGLTF
{
public static class BoneInfoDrawer
{
#region Bone
const string BONE_GIZMO = "Assets/UniGLTF/Editor/UniGLTF/Gizmo/Models/BoneGizmo.prefab";
static GameObject _bone;
static GameObject BonePrefab
{
get
{
if (_bone == null)
{
_bone = AssetDatabase.LoadAssetAtPath<GameObject>(BONE_GIZMO);
}
return _bone;
}
}
private static Mesh _boneMesh;
static Mesh BoneMesh
{
get
{
if (_boneMesh == null)
{
_boneMesh = BonePrefab.GetComponent<MeshFilter>().sharedMesh;
}
return _boneMesh;
}
}
private static Material _boneMaterial;
static Material BoneMaterial
{
get
{
if (_boneMaterial == null)
{
_boneMaterial = BonePrefab.GetComponent<MeshRenderer>().sharedMaterial;
_boneMaterial.enableInstancing = true;
}
return _boneMaterial;
}
}
#endregion
#region Selected
const string SELECTED_BONE_GIZMO = "Assets/UniGLTF/Editor/UniGLTF/Gizmo/Models/SelectedBoneGizmo.prefab";
static GameObject _selected;
static GameObject SelectedPrefab
{
get
{
if (_selected == null)
{
_selected = AssetDatabase.LoadAssetAtPath<GameObject>(SELECTED_BONE_GIZMO);
if (_selected == null)
{
throw new System.NullReferenceException("SelectedPrefab");
}
}
return _selected;
}
}
private static Mesh _selectedBoneMesh;
static Mesh SelectedBoneMesh
{
get
{
if (_selectedBoneMesh == null)
{
_selectedBoneMesh = SelectedPrefab.GetComponent<MeshFilter>().sharedMesh;
}
return _selectedBoneMesh;
}
}
private static Material _selectedMaterial;
public static Material SelectedMaterial
{
get
{
if (_selectedMaterial == null)
{
_selectedMaterial = SelectedPrefab.GetComponent<MeshRenderer>().sharedMaterial;
_selectedMaterial.enableInstancing = true;
}
return _selectedMaterial;
}
}
#endregion
#region Hover
const string HOVER_BONE_GIZMO = "Assets/UniGLTF/Editor/UniGLTF/Gizmo/Models/HoverBoneGizmo.prefab";
static GameObject _hover;
static GameObject HoverPrefab
{
get
{
if (_hover == null)
{
_hover = AssetDatabase.LoadAssetAtPath<GameObject>(HOVER_BONE_GIZMO);
if (_hover == null)
{
throw new System.NullReferenceException("HoverPrefab");
}
}
return _hover;
}
}
private static Mesh _hoverBoneMesh;
static Mesh HoverBoneMesh
{
get
{
if (_hoverBoneMesh == null)
{
_hoverBoneMesh = HoverPrefab.GetComponent<MeshFilter>().sharedMesh;
}
return _hoverBoneMesh;
}
}
private static Material _hoverMaterial;
public static Material HoverMaterial
{
get
{
if (_hoverMaterial == null)
{
_hoverMaterial = HoverPrefab.GetComponent<MeshRenderer>().sharedMaterial;
_hoverMaterial.enableInstancing = true;
}
return _hoverMaterial;
}
}
#endregion
public static void DrawBone(this CommandBuffer buf, BoneInfo bone, Material material)
{
var head = bone.GetHeadPosition();
var tail = bone.GetTailPosition();
var headToTail = tail - head;
var distance = headToTail.magnitude;
var matrix = Matrix4x4.TRS(
head,
Quaternion.LookRotation(headToTail, bone.GetUpVector()),
new Vector3(distance, distance, distance)
);
buf.DrawMesh(SelectedBoneMesh, matrix, material);
}
private const int MaxDrawCount = 256;
private static readonly Matrix4x4[] _maxDrawAtOnceMatrices = new Matrix4x4[MaxDrawCount];
public static void DrawBones(this CommandBuffer buf, List<BoneInfo> bones)
{
var idx = 0;
foreach (var bone in bones)
{
if (idx >= MaxDrawCount) break;
var head = bone.GetHeadPosition();
var tail = bone.GetTailPosition();
var headToTail = tail - head;
var distance = headToTail.magnitude;
_maxDrawAtOnceMatrices[idx++] = Matrix4x4.TRS(
head,
Quaternion.LookRotation(headToTail, bone.GetUpVector()),
new Vector3(distance, distance, distance)
);
}
buf.DrawMeshInstanced(BoneMesh, 0, BoneMaterial, 0, _maxDrawAtOnceMatrices);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c6fcbb0dd0018cf4c81922681f91240c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering;
namespace UniGLTF
{
public class BoneSelector : IDisposable
{
List<BoneInfo> _bones;
Animator _currentAnimator;
public Animator CurrentAnimator
{
set
{
if (_currentAnimator == value)
{
return;
}
if (value == null || value.avatar == null || !value.isHuman)
{
_currentAnimator = null;
return;
}
_currentAnimator = value;
_bones = BoneInfo.GetHumanoidBones(value);
}
}
Camera _sceneViewCamera;
CommandBuffer _commandBuffer;
const CameraEvent _cameraEvent = CameraEvent.AfterForwardAlpha;
BoneInfo _selectedBoneInfo;
public BoneInfo SelectedBoneInfo => _selectedBoneInfo;
BoneInfo _hoverBoneInfo;
public BoneInfo HoverBoneInfo => _hoverBoneInfo;
public BoneSelector(Camera camera)
{
_sceneViewCamera = camera;
_commandBuffer = new CommandBuffer();
_commandBuffer.name = "bones";
_sceneViewCamera.AddCommandBuffer(_cameraEvent, _commandBuffer);
}
public void Dispose()
{
CurrentAnimator = null;
if (_commandBuffer != null)
{
_sceneViewCamera.RemoveCommandBuffer(_cameraEvent, _commandBuffer);
_commandBuffer.Dispose();
_commandBuffer = null;
}
}
public void SetTarget(GameObject activeGameObject)
{
CurrentAnimator = activeGameObject?.GetComponentInParent<Animator>();
}
struct HitResult
{
public Vector3 pos1;
public Vector3 pos2;
public float s;
public float Distance()
{
return Vector3.Distance(pos1, pos2);
}
}
Dictionary<BoneInfo, float> _hitBones = new Dictionary<BoneInfo, float>();
public GameObject IntersectBone(Ray ray, bool isHover = false)
{
if (_bones == null)
{
return null;
}
_hitBones.Clear();
foreach (var boneInfo in _bones)
{
var direction = boneInfo.GetTailPosition() - boneInfo.GetHeadPosition();
HitResult hitResult;
if (GetClosestPosition(boneInfo.GetHeadPosition(), direction, ray, out hitResult))
{
var range = (boneInfo.GetTailPosition() - boneInfo.GetHeadPosition()).magnitude * 0.1f;
if (range > hitResult.Distance())
{
_hitBones.Add(boneInfo, hitResult.s);
}
}
}
// clear
if (isHover)
{
return _IntersectBone(ref _hoverBoneInfo);
}
else
{
return _IntersectBone(ref _selectedBoneInfo);
}
}
GameObject _IntersectBone(ref BoneInfo info)
{
info = null;
if (!_hitBones.Any())
{
return null;
}
var min = _hitBones.Aggregate((result, next) => result.Value < next.Value ? result : next);
// Debug.Log("Hit!! = " + min.Key.HeadBone);
info = min.Key;
return info.HeadObject;
}
private bool GetClosestPosition(Vector3 origin, Vector3 targetDirection, Ray ray, out HitResult hitResult)
{
Vector3 deltaPos3 = origin - ray.origin;
Vector4 deltaPos4 = new Vector4(deltaPos3.x, deltaPos3.y, deltaPos3.z, 0.0f);
Vector3 normal = Vector3.Cross(targetDirection, ray.direction);
if (normal.magnitude < 0.001f)
{
hitResult = default;
return false;
}
Matrix4x4 mat = Matrix4x4.identity;
mat.SetColumn(0, new Vector4(ray.direction.x, ray.direction.y, ray.direction.z, 0.0f));
mat.SetColumn(1, new Vector4(-targetDirection.x, -targetDirection.y, -targetDirection.z, 0.0f));
mat.SetColumn(2, new Vector4(normal.x, normal.y, normal.z, 0.0f));
mat = mat.inverse;
var s = Vector4.Dot(mat.GetRow(0), deltaPos4);
var t = Vector4.Dot(mat.GetRow(1), deltaPos4);
if (s < 0.0f)
{
hitResult = default;
return false;
}
if (s < 0.0f) s = 0.0f;
//if (s > 1.0f) s = 1.0f;
if (t < 0.0f) t = 0.0f;
if (t > 1.0f) t = 1.0f;
var pos1 = ray.direction * s + ray.origin;
var pos2 = targetDirection * t + origin;
hitResult = new HitResult()
{
pos1 = pos1,
pos2 = pos2,
s = s
};
return true;
}
public void Draw()
{
if (_bones == null)
{
return;
}
if (_commandBuffer != null)
{
_commandBuffer.Clear();
_commandBuffer.DrawBones(_bones);
if (_selectedBoneInfo != null)
{
_commandBuffer.DrawBone(_selectedBoneInfo, BoneInfoDrawer.SelectedMaterial);
}
if (_hoverBoneInfo != null && _selectedBoneInfo != _hoverBoneInfo)
{
_commandBuffer.DrawBone(_hoverBoneInfo, BoneInfoDrawer.HoverMaterial);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b71ca936ec0015f418b769181c470025
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c24e9f6c1c4ccfb468194f1d81f0b9c1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,117 @@
fileFormatVersion: 2
guid: 61a60de4cfa7b124184947ca4a57ca53
ModelImporter:
serializedVersion: 19301
internalIDToNameTable:
- first:
1: 100000
second: //RootNode
- first:
4: 400000
second: //RootNode
- first:
23: 2300000
second: //RootNode
- first:
33: 3300000
second: //RootNode
- first:
43: 4300000
second: Cube
externalObjects:
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Bone
second: {fileID: 2100000, guid: de3c6c4e1e6cb6f419be68ef4932dbdc, type: 2}
materials:
materialImportMode: 1
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importVisibility: 0
importBlendShapes: 0
importCameras: 0
importLights: 0
fileIdsGeneration: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 0
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 0
humanoidOversampling: 1
avatarSetup: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,132 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Bone
m_Shader: {fileID: 4800000, guid: 8a83b8ffa4c6d7a44999e8b099ea3f4e, type: 3}
m_ShaderKeywords: _RIMFACTOR_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineWidthTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ReceiveShadowTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _RimTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ShadeTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ShadingGradeTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SphereAdd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _UvAnimMaskTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BlendMode: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5
- _DebugMode: 0
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _IndirectLightIntensity: 0.1
- _LightColorAttenuation: 0
- _MToonVersion: 32
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineColorMode: 0
- _OutlineCullMode: 1
- _OutlineLightingMix: 1
- _OutlineScaledMaxDistance: 1
- _OutlineWidth: 0.5
- _OutlineWidthMode: 0
- _Parallax: 0.02
- _ReceiveShadowRate: 1
- _RimFactor: 1
- _RimFresnelPower: 1
- _RimLift: 0.1
- _RimLightingMix: 0
- _RimReverse: 0.8
- _ShadeShift: 0
- _ShadeToony: 0.9
- _ShadingGradeRate: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _UvAnimRotation: 0
- _UvAnimScrollX: 0
- _UvAnimScrollY: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.5019608, g: 1, b: 0.65572244, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _RimColor: {r: 0, g: 1, b: 1, a: 1}
- _ShadeColor: {r: 0.96999997, g: 0.81, b: 0.86, a: 1}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: de3c6c4e1e6cb6f419be68ef4932dbdc
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,96 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2529445267659295005
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1531572183044127502}
- component: {fileID: 7501372408775426360}
- component: {fileID: 4262291036437626305}
- component: {fileID: 9057427443776596525}
m_Layer: 0
m_Name: BoneGizmo
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1531572183044127502
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7501372408775426360
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_Mesh: {fileID: 4300000, guid: 61a60de4cfa7b124184947ca4a57ca53, type: 3}
--- !u!23 &4262291036437626305
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: de3c6c4e1e6cb6f419be68ef4932dbdc, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &9057427443776596525
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 4300000, guid: d2845ffda163de6479d992107b79b9bd, type: 3}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d0902f1221c08a84687a43326e75bf7e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,132 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HoverBone
m_Shader: {fileID: 4800000, guid: 8a83b8ffa4c6d7a44999e8b099ea3f4e, type: 3}
m_ShaderKeywords: _RIMFACTOR_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineWidthTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ReceiveShadowTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _RimTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ShadeTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ShadingGradeTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SphereAdd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _UvAnimMaskTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BlendMode: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5
- _DebugMode: 0
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _IndirectLightIntensity: 0.1
- _LightColorAttenuation: 0
- _MToonVersion: 32
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineColorMode: 0
- _OutlineCullMode: 1
- _OutlineLightingMix: 1
- _OutlineScaledMaxDistance: 1
- _OutlineWidth: 0.5
- _OutlineWidthMode: 0
- _Parallax: 0.02
- _ReceiveShadowRate: 1
- _RimFactor: 1
- _RimFresnelPower: 1
- _RimLift: 0.1
- _RimLightingMix: 0
- _RimReverse: 0.8
- _ShadeShift: 0
- _ShadeToony: 0.9
- _ShadingGradeRate: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _UvAnimRotation: 0
- _UvAnimScrollX: 0
- _UvAnimScrollY: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 0, b: 0.13911295, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _RimColor: {r: 0, g: 1, b: 1, a: 1}
- _ShadeColor: {r: 0.96999997, g: 0.81, b: 0.86, a: 1}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3074a2fc6fdd2f24d896038be6eebe6a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2529445267659295005
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1531572183044127502}
- component: {fileID: 7501372408775426360}
- component: {fileID: 4262291036437626305}
m_Layer: 0
m_Name: HoverBoneGizmo
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1531572183044127502
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7501372408775426360
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_Mesh: {fileID: 4300000, guid: 61a60de4cfa7b124184947ca4a57ca53, type: 3}
--- !u!23 &4262291036437626305
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 3074a2fc6fdd2f24d896038be6eebe6a, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fbf7ad78b397b0749bb8132dfbc87f44
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,82 @@
Shader "CloverUI/OverlayGizmo"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
[Toggle] _RimFactor ("Rim", Float) = 0
[PowerSlider(4.0)] _RimFresnelPower ("Rim Fresnel Power", Range(0, 100)) = 1
_RimLift ("Rim Lift", Range(0, 1)) = 0
_RimReverse ("Rim Reverse", Range(0, 1)) = 0
}
SubShader
{
Tags { "RenderType"="Overlay" "Queue"="Overlay" }
LOD 100
Pass
{
Lighting Off
ZTest Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float4 posWorld : TEXCOORD0;
float2 uv : TEXCOORD1;
float3 normal : TEXCOORD2;
};
half4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
half _RimFactor;
half _RimFresnelPower;
half _RimLift;
half _RimReverse;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.normal = UnityObjectToWorldNormal(v.normal);
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
return o;
}
half4 frag (v2f i) : SV_Target
{
float3 worldNormal = normalize(i.normal);
float3 worldView = normalize(lerp(_WorldSpaceCameraPos.xyz - i.posWorld.xyz, UNITY_MATRIX_V[2].xyz, unity_OrthoParams.w));
half4 col = _Color * tex2D(_MainTex, i.uv);
half rim = pow(saturate(dot(worldNormal, worldView)), _RimFresnelPower);
rim = (1 - _RimReverse) * rim + _RimReverse * (1 - rim);
rim += _RimLift;
col = (1 - _RimFactor) * col + _RimFactor * (col * rim);
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8a83b8ffa4c6d7a44999e8b099ea3f4e
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,132 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: SelectedBone
m_Shader: {fileID: 4800000, guid: 8a83b8ffa4c6d7a44999e8b099ea3f4e, type: 3}
m_ShaderKeywords: _RIMFACTOR_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineWidthTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ReceiveShadowTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _RimTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ShadeTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ShadingGradeTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SphereAdd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _UvAnimMaskTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BlendMode: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5
- _DebugMode: 0
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _IndirectLightIntensity: 0.1
- _LightColorAttenuation: 0
- _MToonVersion: 32
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineColorMode: 0
- _OutlineCullMode: 1
- _OutlineLightingMix: 1
- _OutlineScaledMaxDistance: 1
- _OutlineWidth: 0.5
- _OutlineWidthMode: 0
- _Parallax: 0.02
- _ReceiveShadowRate: 1
- _RimFactor: 1
- _RimFresnelPower: 1
- _RimLift: 0.1
- _RimLightingMix: 0
- _RimReverse: 0.8
- _ShadeShift: 0
- _ShadeToony: 0.9
- _ShadingGradeRate: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _UvAnimRotation: 0
- _UvAnimScrollX: 0
- _UvAnimScrollY: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 0, b: 0.13911295, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _RimColor: {r: 0, g: 1, b: 1, a: 1}
- _ShadeColor: {r: 0.96999997, g: 0.81, b: 0.86, a: 1}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dc0c884ca4cfbbd458f2350c25cb7e9d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2529445267659295005
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1531572183044127502}
- component: {fileID: 7501372408775426360}
- component: {fileID: 4262291036437626305}
m_Layer: 0
m_Name: SelectedBoneGizmo
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1531572183044127502
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7501372408775426360
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_Mesh: {fileID: 4300000, guid: 61a60de4cfa7b124184947ca4a57ca53, type: 3}
--- !u!23 &4262291036437626305
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2529445267659295005}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: dc0c884ca4cfbbd458f2350c25cb7e9d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 65aed222118a19e46a4d35c654cd818e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,123 @@
using UnityEngine;
using UnityEditor;
using UnityEditor.EditorTools;
using UniGLTF;
namespace UniVRM10
{
/// <summary>
/// Bone Selector
/// </summary>
[EditorTool("vrm-1.0/Humanoid", typeof(UniVRM10.VRM10Controller))]
public class VRM10BoneSelectorEditorTool : EditorTool
{
static GUIContent s_cachedIcon;
public override GUIContent toolbarIcon
{
get
{
if (s_cachedIcon == null)
{
s_cachedIcon = EditorGUIUtility.IconContent("AvatarSelector@2x", "|vrm-1.0 Humanoid");
}
return s_cachedIcon;
}
}
BoneSelector _impl;
void OnEnable()
{
EditorTools.activeToolChanged += ActiveToolDidChange;
if (SceneView.lastActiveSceneView?.camera)
{
}
}
void OnDisable()
{
EditorTools.activeToolChanged -= ActiveToolDidChange;
if (_impl != null)
{
_impl.Dispose();
_impl = null;
}
}
void ActiveToolDidChange()
{
if (EditorTools.IsActiveTool(this))
{
}
else
{
if (_impl != null)
{
_impl.Dispose();
_impl = null;
}
}
}
public override void OnToolGUI(EditorWindow window)
{
if (_impl == null)
{
_impl = new BoneSelector(SceneView.lastActiveSceneView.camera);
}
var root = Selection.activeGameObject?.GetComponent<VRM10Controller>();
if (root == null)
{
return;
}
_impl.SetTarget(root.gameObject);
if (Event.current.type == EventType.Repaint)
{
_impl.Draw();
}
// bone manipulator
var selected = _impl.SelectedBoneInfo;
bool selector = true;
if (selected != null)
{
EditorGUI.BeginChangeCheck();
Quaternion rot = Handles.RotationHandle(selected.HeadObject.transform.rotation, selected.HeadObject.transform.position);
// Debug.Log($"{selected}");
if (EditorGUI.EndChangeCheck())
{
// UNDO
Undo.RecordObject(selected.HeadObject.transform, "bone rotation");
// apply
selected.HeadObject.transform.rotation = rot;
selector = false;
}
}
if (selector)
{
if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
{
// 回転ギズモがなんもしなかった
// selector
Vector2 mousePosition = Event.current.mousePosition;
Ray ray = HandleUtility.GUIPointToWorldRay(mousePosition);
Event e = Event.current;
_impl.IntersectBone(ray);
}
else if (Event.current.type == EventType.MouseMove)
{
// hover
Vector2 mousePosition = Event.current.mousePosition;
Ray ray = HandleUtility.GUIPointToWorldRay(mousePosition);
Event e = Event.current;
_impl.IntersectBone(ray, true);
}
}
// disable sceneView select
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9da1932d34ba48e45a409547a0ad30bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: