mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-07 19:38:13 -05:00
Merge pull request #2253 from ousttrue/fix/vrm10_springbone_inspector_migration
[vrm10] SpringBone の inspector 修正など
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(VRM10SpringBoneColliderGroup))]
|
||||
public class VRM10SpringBoneColliderGroupDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
try
|
||||
{
|
||||
EditorGUI.ObjectField(rect, property, new GUIContent(((VRM10SpringBoneColliderGroup)property.objectReferenceValue).Name));
|
||||
}
|
||||
catch
|
||||
{
|
||||
EditorGUI.ObjectField(rect, property, new GUIContent("fallback"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f5afdd3051fad24e9c7cb8caa29dc7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -554,6 +554,7 @@ namespace UniVRM10
|
||||
foreach (var g in gltfVrmSpringBone.ColliderGroups)
|
||||
{
|
||||
var colliderGroup = secondary.gameObject.AddComponent<VRM10SpringBoneColliderGroup>();
|
||||
colliderGroup.Name = g.Name;
|
||||
controller.SpringBone.ColliderGroups.Add(colliderGroup);
|
||||
|
||||
if (g != null && g.Colliders != null)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniGLTF.Extensions.VRMC_springBone;
|
||||
using UniJSON;
|
||||
@@ -48,6 +49,23 @@ namespace UniVRM10
|
||||
MigrateRootBone(vrm0Bone.GetInt32());
|
||||
}
|
||||
}
|
||||
|
||||
// fallback. default spring names
|
||||
foreach (var spring in _springs)
|
||||
{
|
||||
if (string.IsNullOrEmpty(spring.Name) && spring.Joints.Count > 0 && spring.Joints[0].Node.HasValue)
|
||||
{
|
||||
var i = spring.Joints[0].Node.Value;
|
||||
if (i >= 0 && i < _gltf.nodes.Count)
|
||||
{
|
||||
spring.Name = _gltf.nodes[i].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(_comment) && _springs.Count > 0)
|
||||
{
|
||||
_comment = _springs[0].Name;
|
||||
}
|
||||
}
|
||||
|
||||
Spring CreateSpring()
|
||||
@@ -263,6 +281,15 @@ namespace UniVRM10
|
||||
{
|
||||
Colliders = colliderIndices.ToArray(),
|
||||
};
|
||||
if (colliderGroup.Colliders.Length > 0 && springBone.Colliders[colliderGroup.Colliders[0]].Node.HasValue)
|
||||
{
|
||||
var i = springBone.Colliders[colliderGroup.Colliders[0]].Node.Value;
|
||||
if (i >= 0 && i < gltf.nodes.Count)
|
||||
{
|
||||
var node = gltf.nodes[i];
|
||||
colliderGroup.Name = node.name;
|
||||
}
|
||||
}
|
||||
springBone.ColliderGroups.Add(colliderGroup);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user