mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-11 23:19:00 +08:00
Merge branch 'main' into merge-replace-animator
This commit is contained in:
commit
4905a6d060
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- [#1482] `Merge Animator` に既存のアニメーターコントローラーを置き換える機能を追加
|
- [#1482] `Merge Animator` に既存のアニメーターコントローラーを置き換える機能を追加
|
||||||
|
- [#1481] [World Scale Object](https://m-a.nadena.dev/dev/ja/docs/reference/world-scale-object)を追加
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- [#1482] Added support for replacing pre-existing animator controllers to `Merge Animator`
|
- [#1482] Added support for replacing pre-existing animator controllers to `Merge Animator`
|
||||||
-
|
- [#1481] Added [World Scale Object](https://m-a.nadena.dev/dev/docs/reference/world-scale-object)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -11,6 +11,7 @@ Modular Avatarの主な変更点をこのファイルで記録しています。
|
|||||||
### Added
|
### Added
|
||||||
- CHANGELOGファイルを追加
|
- CHANGELOGファイルを追加
|
||||||
- [#1482] `Merge Animator` に既存のアニメーターコントローラーを置き換える機能を追加
|
- [#1482] `Merge Animator` に既存のアニメーターコントローラーを置き換える機能を追加
|
||||||
|
- [#1481] [World Scale Object](https://m-a.nadena.dev/ja/docs/reference/world-scale-object)を追加
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- [#1460] パラメーターアセットをMA Parametersにインポートするとき、ローカルのみのパラメーターが間違ってアニメーターのみ扱いになる問題を修正
|
- [#1460] パラメーターアセットをMA Parametersにインポートするとき、ローカルのみのパラメーターが間違ってアニメーターのみ扱いになる問題を修正
|
||||||
|
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
- Added CHANGELOG files
|
- Added CHANGELOG files
|
||||||
- [#1482] Added support for replacing pre-existing animator controllers to `Merge Animator`
|
- [#1482] Added support for replacing pre-existing animator controllers to `Merge Animator`
|
||||||
|
- [#1481] Added [World Scale Object](https://m-a.nadena.dev/docs/reference/world-scale-object)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- [#1460] When importing parameter assets in MA Parameters, "local only" parameters were incorrectly treated as
|
- [#1460] When importing parameter assets in MA Parameters, "local only" parameters were incorrectly treated as
|
||||||
|
12
Editor/Inspector/WorldScaleObjectEditor.cs
Normal file
12
Editor/Inspector/WorldScaleObjectEditor.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace nadena.dev.modular_avatar.core.editor
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(ModularAvatarWorldScaleObject))]
|
||||||
|
internal class WorldScaleObjectEditor : MAEditorBase
|
||||||
|
{
|
||||||
|
protected override void OnInnerInspectorGUI()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Editor/Inspector/WorldScaleObjectEditor.cs.meta
Normal file
3
Editor/Inspector/WorldScaleObjectEditor.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9b8b83586074bd7a6441b4cd7539dc9
|
||||||
|
timeCreated: 1741658287
|
@ -84,6 +84,7 @@ namespace nadena.dev.modular_avatar.core.editor.plugin
|
|||||||
seq.Run("World Fixed Object",
|
seq.Run("World Fixed Object",
|
||||||
ctx => new WorldFixedObjectProcessor().Process(ctx)
|
ctx => new WorldFixedObjectProcessor().Process(ctx)
|
||||||
);
|
);
|
||||||
|
seq.Run(WorldScaleObjectPass.Instance);
|
||||||
|
|
||||||
seq.Run(ReplaceObjectPluginPass.Instance);
|
seq.Run(ReplaceObjectPluginPass.Instance);
|
||||||
|
|
||||||
|
46
Editor/WorldScaleObjectPass.cs
Normal file
46
Editor/WorldScaleObjectPass.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using nadena.dev.modular_avatar.editor.ErrorReporting;
|
||||||
|
using nadena.dev.ndmf;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
#if VRC_SDK_VRCSDK3
|
||||||
|
using VRC.Dynamics;
|
||||||
|
using VRC.SDK3.Dynamics.Constraint.Components;
|
||||||
|
|
||||||
|
#else
|
||||||
|
using UnityEngine.Animations;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace nadena.dev.modular_avatar.core.editor
|
||||||
|
{
|
||||||
|
internal class WorldScaleObjectPass : Pass<WorldScaleObjectPass>
|
||||||
|
{
|
||||||
|
protected override void Execute(ndmf.BuildContext context)
|
||||||
|
{
|
||||||
|
var fixedPrefab =
|
||||||
|
AssetDatabase.LoadAssetAtPath<GameObject>(
|
||||||
|
"Packages/nadena.dev.modular-avatar/Assets/FixedPrefab.prefab"
|
||||||
|
);
|
||||||
|
var targets = context.AvatarRootTransform.GetComponentsInChildren<ModularAvatarWorldScaleObject>(true);
|
||||||
|
|
||||||
|
foreach (var target in targets)
|
||||||
|
{
|
||||||
|
BuildReport.ReportingObject(target, () =>
|
||||||
|
{
|
||||||
|
#if MA_VRCSDK3_AVATARS
|
||||||
|
var c = target.gameObject.AddComponent<VRCScaleConstraint>();
|
||||||
|
c.Sources.Add(new VRCConstraintSource(fixedPrefab.transform, 1));
|
||||||
|
c.Locked = true;
|
||||||
|
c.IsActive = true;
|
||||||
|
#else
|
||||||
|
var c = target.gameObject.AddComponent<ScaleConstraint>();
|
||||||
|
c.AddSource(new ConstraintSource() {sourceTransform = fixedPrefab.transform, weight = 1});
|
||||||
|
c.locked = true;
|
||||||
|
c.constraintActive = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Object.DestroyImmediate(target);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Editor/WorldScaleObjectPass.cs.meta
Normal file
3
Editor/WorldScaleObjectPass.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 19a3b07a9eeb413887792469f344c34d
|
||||||
|
timeCreated: 1741657804
|
@ -29,7 +29,8 @@
|
|||||||
"VRC.SDK3.Dynamics.Contact.Editor.dll",
|
"VRC.SDK3.Dynamics.Contact.Editor.dll",
|
||||||
"VRC.SDK3.Dynamics.PhysBone.dll",
|
"VRC.SDK3.Dynamics.PhysBone.dll",
|
||||||
"VRC.SDK3.Dynamics.PhysBone.Editor.dll",
|
"VRC.SDK3.Dynamics.PhysBone.Editor.dll",
|
||||||
"VRCCore-Editor.dll"
|
"VRCCore-Editor.dll",
|
||||||
|
"VRC.SDK3.Dynamics.Constraint.dll"
|
||||||
],
|
],
|
||||||
"autoReferenced": false,
|
"autoReferenced": false,
|
||||||
"defineConstraints": [],
|
"defineConstraints": [],
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nadena.dev.modular-avatar.core.editor",
|
|
||||||
"rootNamespace": "",
|
|
||||||
"references": [
|
|
||||||
"nadena.dev.modular-avatar.core",
|
|
||||||
"VRC.SDK3A",
|
|
||||||
"VRC.SDKBase",
|
|
||||||
"nadena.dev.ndmf",
|
|
||||||
"nadena.dev.ndmf.vrchat",
|
|
||||||
"nadena.dev.ndmf.runtime",
|
|
||||||
"VRC.SDK3A.Editor",
|
|
||||||
"Unity.Burst"
|
|
||||||
],
|
|
||||||
"includePlatforms": [
|
|
||||||
"Editor"
|
|
||||||
],
|
|
||||||
"excludePlatforms": [],
|
|
||||||
"allowUnsafeCode": false,
|
|
||||||
"overrideReferences": true,
|
|
||||||
"precompiledReferences": [
|
|
||||||
"Newtonsoft.Json.dll",
|
|
||||||
"System.Collections.Immutable.dll",
|
|
||||||
"VRCSDKBase.dll",
|
|
||||||
"VRCSDKBase-Editor.dll",
|
|
||||||
"VRCSDK3A.dll",
|
|
||||||
"VRCSDK3A-Editor.dll",
|
|
||||||
"VRC.Dynamics.dll",
|
|
||||||
"VRC.SDK3.Dynamics.Contact.dll",
|
|
||||||
"VRC.SDK3.Dynamics.Contact.Editor.dll",
|
|
||||||
"VRC.SDK3.Dynamics.PhysBone.dll",
|
|
||||||
"VRC.SDK3.Dynamics.PhysBone.Editor.dll",
|
|
||||||
"VRCCore-Editor.dll"
|
|
||||||
],
|
|
||||||
"autoReferenced": false,
|
|
||||||
"defineConstraints": [],
|
|
||||||
"versionDefines": [
|
|
||||||
{
|
|
||||||
"name": "com.anatawa12.avatar-optimizer",
|
|
||||||
"expression": "(,1.5.0-rc.8)",
|
|
||||||
"define": "LEGACY_AVATAR_OPTIMIZER"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.vrchat.avatars",
|
|
||||||
"expression": "",
|
|
||||||
"define": "MA_VRCSDK3_AVATARS"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.vrchat.avatars",
|
|
||||||
"expression": "3.5.2",
|
|
||||||
"define": "MA_VRCSDK3_AVATARS_3_5_2_OR_NEWER"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.vrchat.avatars",
|
|
||||||
"expression": "3.7.0-beta.2",
|
|
||||||
"define": "MA_VRCSDK3_AVATARS_3_7_0_OR_NEWER"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"noEngineReferences": false
|
|
||||||
}
|
|
12
Runtime/ModularAvatarWorldScaleObject.cs
Normal file
12
Runtime/ModularAvatarWorldScaleObject.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace nadena.dev.modular_avatar.core
|
||||||
|
{
|
||||||
|
[AddComponentMenu("Modular Avatar/MA World Scale Object")]
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
[HelpURL("https://modular-avatar.nadena.dev/docs/reference/world-scale-object?lang=auto")]
|
||||||
|
public class ModularAvatarWorldScaleObject : AvatarTagComponent
|
||||||
|
{
|
||||||
|
// no configuration
|
||||||
|
}
|
||||||
|
}
|
11
Runtime/ModularAvatarWorldScaleObject.cs.meta
Normal file
11
Runtime/ModularAvatarWorldScaleObject.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e113c01563a14226b5e863befe6fe769
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {fileID: 2800000, guid: a8edd5bd1a0a64a40aa99cc09fb5f198, type: 3}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
3
UnitTests~/WorldScaleObject.meta
Normal file
3
UnitTests~/WorldScaleObject.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2ce1741d17804d6c94f296ef930afba8
|
||||||
|
timeCreated: 1741658553
|
58
UnitTests~/WorldScaleObject/WorldScaleObjectTest.cs
Normal file
58
UnitTests~/WorldScaleObject/WorldScaleObjectTest.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using modular_avatar_tests;
|
||||||
|
using nadena.dev.modular_avatar.core;
|
||||||
|
using nadena.dev.modular_avatar.core.editor;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Animations;
|
||||||
|
|
||||||
|
#if MA_VRCSDK3_AVATARS
|
||||||
|
using VRC.SDK3.Dynamics.Constraint.Components;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace UnitTests.WorldScaleObject
|
||||||
|
{
|
||||||
|
public class WorldScaleObjectTest : TestBase
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestWSO()
|
||||||
|
{
|
||||||
|
var root = CreateRoot("root");
|
||||||
|
var child = CreateChild(root, "child");
|
||||||
|
var wso = child.AddComponent<ModularAvatarWorldScaleObject>();
|
||||||
|
|
||||||
|
AvatarProcessor.ProcessAvatar(root);
|
||||||
|
|
||||||
|
Assert.IsTrue(wso == null);
|
||||||
|
|
||||||
|
#if MA_VRCSDK3_AVATARS
|
||||||
|
AssertVRCScaleConstraintPresent(child);
|
||||||
|
#else
|
||||||
|
AssertScaleConstraintPresent(child);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MA_VRCSDK3_AVATARS
|
||||||
|
private void AssertVRCScaleConstraintPresent(GameObject child)
|
||||||
|
{
|
||||||
|
var scaleConstraint = child.GetComponent<VRCScaleConstraint>();
|
||||||
|
Assert.IsNotNull(scaleConstraint);
|
||||||
|
Assert.AreEqual(1, scaleConstraint.Sources.Count);
|
||||||
|
Assert.AreEqual("FixedPrefab", scaleConstraint.Sources[0].SourceTransform.gameObject.name);
|
||||||
|
Assert.AreEqual(1, scaleConstraint.Sources[0].Weight);
|
||||||
|
Assert.AreEqual(true, scaleConstraint.Locked);
|
||||||
|
Assert.AreEqual(true, scaleConstraint.IsActive);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private void AssertScaleConstraintPresent(GameObject child)
|
||||||
|
{
|
||||||
|
var scaleConstraint = child.GetComponent<ScaleConstraint>();
|
||||||
|
Assert.IsNotNull(scaleConstraint);
|
||||||
|
Assert.AreEqual(1, scaleConstraint.sourceCount);
|
||||||
|
Assert.AreEqual("FixedPrefab", scaleConstraint.GetSource(0).sourceTransform.gameObject.name);
|
||||||
|
Assert.AreEqual(1, scaleConstraint.GetSource(0).weight);
|
||||||
|
Assert.AreEqual(true, scaleConstraint.locked);
|
||||||
|
Assert.AreEqual(true, scaleConstraint.constraintActive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
UnitTests~/WorldScaleObject/WorldScaleObjectTest.cs.meta
Normal file
3
UnitTests~/WorldScaleObject/WorldScaleObjectTest.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 41ec840868664e28bd0546a3cc639692
|
||||||
|
timeCreated: 1741658559
|
17
docs~/docs/reference/world-scale-object.md
Normal file
17
docs~/docs/reference/world-scale-object.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# World Scale Object
|
||||||
|
|
||||||
|
This component can be used to force a game object to have the same scale as the world, regardless of the current avatar
|
||||||
|
scale. It will attach a (VRC) Scale Constraint to the game object, and set the constraint to scale to 1,1,1 scale relative
|
||||||
|
to the world.
|
||||||
|
|
||||||
|
## When should I use it?
|
||||||
|
|
||||||
|
When you want to have a game object scale with the world, rather than the avatar. This can be useful in certain complex
|
||||||
|
constraint gimmicks.
|
||||||
|
|
||||||
|
## Setting up World Scale Object
|
||||||
|
|
||||||
|
Simply attach the `World Scale Object` component to a GameObject. There are no configuration options to set.
|
||||||
|
|
||||||
|
Note that `World Scale Object` currently is not previewed in the Unity Editor, but will work correctly in-game or in
|
||||||
|
play mode.
|
@ -0,0 +1,14 @@
|
|||||||
|
# World Scale Object
|
||||||
|
|
||||||
|
このコンポーネントは、現在のアバタースケールに関係なく、ゲームオブジェクトをワールドと同じスケールにするために使用できます。
|
||||||
|
ゲームオブジェクトにScaleConstraintまたはVRCScaleConstraintをアタッチし、1,1,1スケールに設定して、世界に対してスケールを固定します。
|
||||||
|
|
||||||
|
## いつ使うべきか?
|
||||||
|
|
||||||
|
アバターではなく、ワールドと一緒にスケールするゲームオブジェクトが必要な場合に使用します。特定の複雑なコンストレイントギミックなどで便利です。
|
||||||
|
|
||||||
|
## World Scale Objectの設定
|
||||||
|
|
||||||
|
単純に`World Scale Object`コンポーネントをゲームオブジェクトにアタッチするだけです。詳細設定はありません。
|
||||||
|
|
||||||
|
なお、`World Scale Object`は現在Unityエディターでプレビューされませんが、ゲーム内またはプレイモードで正常に動作します。
|
Loading…
x
Reference in New Issue
Block a user