void OnWizardUpdate() { if (BoneSettingName == null) { BoneSettingName = new string[boneObjects.Length]; for (int i = 0; i < boneObjects.Length; i++) { VRMSpringBoneSetting setting = (VRMSpringBoneSetting)boneObjects[i]; BoneSettingName[i] = setting.RootBones[0]; if (setting.m_comment == "") { BoneSettingName[i] = "右のボーンを含む→" + setting.RootBones[0]; } else { BoneSettingName[i] = setting.m_comment; } } } if (ColliderSettingName == null) { ColliderSettingName = new string[colliderObjects.Length]; for (int i = 0; i < colliderObjects.Length; i++) { VRMSpringBoneColliderSetting setting = (VRMSpringBoneColliderSetting)colliderObjects[i]; ColliderSettingName[i] = setting.TargetName; } } }
void ApplyVRMSpringBoneCollider() { //gizmo以外は設定を反映する for (int j = 0; j < colliderObjects.Length; j++) { VRMSpringBoneColliderSetting settingData = (VRMSpringBoneColliderSetting)colliderObjects[j]; GameObject targetObject = GameObject.Find(settingData.TargetName); VRMSpringBoneColliderGroup[] removeComponents = targetObject.GetComponents <VRMSpringBoneColliderGroup>(); //すべて削除してからコライダーをつける foreach (VRMSpringBoneColliderGroup removeComponent in removeComponents) { DestroyImmediate(removeComponent); } VRMSpringBoneColliderGroup collider = targetObject.AddComponent <VRMSpringBoneColliderGroup>(); collider.Colliders = new VRMSpringBoneColliderGroup.SphereCollider[settingData.Colliders.Length]; for (int i = 0; i < settingData.Colliders.Length; i++) { collider.Colliders[i] = new VRMSpringBoneColliderGroup.SphereCollider(); collider.Colliders[i].Radius = settingData.Colliders[i].Radius; collider.Colliders[i].Offset = settingData.Colliders[i].Offset; } } }
void ApplyDynamicBoneCollider() { //gizmo以外は設定を反映する for (int j = 0; j < colliderObjects.Length; j++) { VRMSpringBoneColliderSetting settingData = (VRMSpringBoneColliderSetting)colliderObjects[j]; GameObject targetObject = GameObject.Find(settingData.TargetName); for (int i = 0; i < settingData.Colliders.Length; i++) { DynamicBoneCollider collider = targetObject.AddComponent <DynamicBoneCollider>(); collider.m_Center = settingData.Colliders[i].Offset; collider.m_Radius = settingData.Colliders[i].Radius; } } }
void ExportVRMSpringBoneCollider() { //gizmo以外はエクスポート for (int j = 0; j < ColliderTergetName.Count; j++) { GameObject colliderObject = GameObject.Find(ColliderTergetName[j]); VRMSpringBoneColliderGroup collider = colliderObject.GetComponent <VRMSpringBoneColliderGroup>(); VRMSpringBoneColliderSetting exportData = ScriptableObject.CreateInstance <VRMSpringBoneColliderSetting>(); exportData.TargetName = m_Utility.GetHierarchyPath(colliderObject.transform); exportData.Colliders = new VRMSpringBoneColliderSetting.SphereCollider[collider.Colliders.Length]; for (int i = 0; i < collider.Colliders.Length; i++) { exportData.Colliders[i] = new VRMSpringBoneColliderSetting.SphereCollider(); exportData.Colliders[i].Radius = collider.Colliders[i].Radius; exportData.Colliders[i].Offset = collider.Colliders[i].Offset; } AssetDatabase.CreateAsset( exportData, "Assets/Models/Resources/SpringBoneData/Collider/VRMSpringBoneColliderData_" + j + ".asset"); } }
void ApplyVRMSpringBoneCollider() { //gizmo以外は設定を反映する for (int j = 0; j < colliderObjects.Length; j++) { VRMSpringBoneColliderSetting settingData = (VRMSpringBoneColliderSetting)colliderObjects[j]; //対象のボーン //m_Utility.ChangeRootPath 設定されたパスをターゲット対象に変更する GameObject targetObject = GameObject.Find(m_Utility.ChangeRootPath(settingData.TargetName, targetModel.name)); VRMSpringBoneColliderGroup collider = targetObject.AddComponent <VRMSpringBoneColliderGroup>(); collider.Colliders = new VRMSpringBoneColliderGroup.SphereCollider[settingData.Colliders.Length]; for (int i = 0; i < settingData.Colliders.Length; i++) { collider.Colliders[i] = new VRMSpringBoneColliderGroup.SphereCollider(); collider.Colliders[i].Radius = settingData.Colliders[i].Radius; collider.Colliders[i].Offset = settingData.Colliders[i].Offset; } } }