generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AvatarRoot API: Non-VRChat avatar support in VRCSDK projects #71
Closed
Closed
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e01ccf7
add runtime VRM defines and asmdef references
kaikoga cebd6be
add test VRM defines and asmdef references
kaikoga 25e047c
fix avatar root detection
kaikoga 10545ea
really add test VRM defines and asmdef references
kaikoga 0893781
add changelog
kaikoga 3a3bcc1
prevent modification while iteration
kaikoga fa1ebb6
Merge branch 'main' into avatar_root_true_xp
kaikoga 3547fd3
allow generic avatars in VRChat and/or VRM projects
kaikoga 976dc74
add TODO comment
kaikoga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
using nadena.dev.ndmf.runtime; | ||
using NUnit.Framework; | ||
using UnityEngine; | ||
|
||
namespace UnitTests.AvatarRootTests | ||
{ | ||
public class AvatarRoot : TestBase | ||
{ | ||
private GameObject CreateGenericRoot(string name) => CreatePlatformRoot(name, isVRC: false, isVRM0: false, isVRM1: false); | ||
private GameObject CreateVRCRoot(string name) => CreatePlatformRoot(name, isVRC: true, isVRM0: false, isVRM1: false); | ||
private GameObject CreateVRM0Root(string name) => CreatePlatformRoot(name, isVRC: false, isVRM0: true, isVRM1: false); | ||
private GameObject CreateVRM1Root(string name) => CreatePlatformRoot(name, isVRC: false, isVRM0: false, isVRM1: true); | ||
private GameObject CreateHybridRoot(string name) => CreatePlatformRoot(name, isVRC: true, isVRM0: true, isVRM1: true); | ||
|
||
private Transform parentAvatar; | ||
private Transform childAvatar; | ||
|
||
private void NoAvatars() | ||
{ | ||
Assert.That(RuntimeUtil.IsAvatarRoot(parentAvatar), Is.False); | ||
Assert.That(RuntimeUtil.IsAvatarRoot(childAvatar), Is.False); | ||
Assert.That(RuntimeUtil.FindAvatarInParents(parentAvatar), Is.Null); | ||
Assert.That(RuntimeUtil.FindAvatarInParents(childAvatar), Is.Null); | ||
Assert.That(RuntimeUtil.FindAvatarsInScene(parentAvatar.gameObject.scene), Is.EquivalentTo(System.Array.Empty<Transform>())); | ||
} | ||
|
||
private void ParentIsAvatar() | ||
{ | ||
Assert.That(RuntimeUtil.IsAvatarRoot(parentAvatar), Is.True); | ||
Assert.That(RuntimeUtil.IsAvatarRoot(childAvatar), Is.False); | ||
Assert.That(RuntimeUtil.FindAvatarInParents(parentAvatar), Is.EqualTo(parentAvatar)); | ||
Assert.That(RuntimeUtil.FindAvatarInParents(childAvatar), Is.EqualTo(parentAvatar)); | ||
Assert.That(RuntimeUtil.FindAvatarsInScene(parentAvatar.gameObject.scene), Is.EquivalentTo(new [] { parentAvatar })); | ||
} | ||
|
||
private void ChildIsAvatar() | ||
{ | ||
Assert.That(RuntimeUtil.IsAvatarRoot(parentAvatar), Is.False); | ||
Assert.That(RuntimeUtil.IsAvatarRoot(childAvatar), Is.True); | ||
Assert.That(RuntimeUtil.FindAvatarInParents(parentAvatar), Is.EqualTo(null)); | ||
Assert.That(RuntimeUtil.FindAvatarInParents(childAvatar), Is.EqualTo(childAvatar)); | ||
Assert.That(RuntimeUtil.FindAvatarsInScene(parentAvatar.gameObject.scene), Is.EquivalentTo(new [] { childAvatar })); | ||
} | ||
|
||
private void ParentAndChildAreAvatars() | ||
{ | ||
Assert.That(RuntimeUtil.IsAvatarRoot(parentAvatar), Is.True); | ||
Assert.That(RuntimeUtil.IsAvatarRoot(childAvatar), Is.True); | ||
Assert.That(RuntimeUtil.FindAvatarInParents(parentAvatar), Is.EqualTo(parentAvatar)); | ||
Assert.That(RuntimeUtil.FindAvatarInParents(childAvatar), Is.EqualTo(childAvatar)); | ||
Assert.That(RuntimeUtil.FindAvatarsInScene(parentAvatar.gameObject.scene), Is.EquivalentTo(new [] { parentAvatar, childAvatar })); | ||
} | ||
|
||
[Test] | ||
public void TestGenericContainsGeneric() | ||
{ | ||
parentAvatar = CreateGenericRoot("parent").transform; | ||
childAvatar = CreateGenericRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
#if NDMF_VRCSDK3_AVATARS || NDMF_VRM0 || NDMF_VRM1 | ||
NoAvatars(); | ||
#else | ||
// Use fallback heuristic | ||
ParentIsAvatar(); | ||
#endif | ||
} | ||
|
||
#if NDMF_VRCSDK3_AVATARS | ||
[Test] | ||
public void TestGenericContainsVRC() | ||
{ | ||
parentAvatar = CreateGenericRoot("parent").transform; | ||
childAvatar = CreateVRCRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ChildIsAvatar(); | ||
} | ||
|
||
[Test] | ||
public void TestVRCContainsGeneric() | ||
{ | ||
parentAvatar = CreateVRCRoot("parent").transform; | ||
childAvatar = CreateGenericRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ParentIsAvatar(); | ||
} | ||
|
||
[Test] | ||
public void TestVRCContainsVRC() | ||
{ | ||
parentAvatar = CreateVRCRoot("parent").transform; | ||
childAvatar = CreateVRCRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ParentAndChildAreAvatars(); | ||
} | ||
#endif | ||
|
||
#if NDMF_VRM0 | ||
[Test] | ||
public void TestGenericContainsVRM0() | ||
{ | ||
parentAvatar = CreateGenericRoot("parent").transform; | ||
childAvatar = CreateVRM1Root("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ChildIsAvatar(); | ||
} | ||
|
||
[Test] | ||
public void TestVRM0ContainsGeneric() | ||
{ | ||
parentAvatar = CreateVRM1Root("parent").transform; | ||
childAvatar = CreateGenericRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ParentIsAvatar(); | ||
} | ||
|
||
[Test] | ||
public void TestVRM0ContainsVRM0() | ||
{ | ||
parentAvatar = CreateVRM1Root("parent").transform; | ||
childAvatar = CreateVRM1Root("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ParentAndChildAreAvatars(); | ||
} | ||
#endif | ||
|
||
#if NDMF_VRCSDK3_AVATARS && NDMF_VRM0 | ||
[Test] | ||
public void TestGenericContainsHybrid() | ||
{ | ||
parentAvatar = CreateGenericRoot("parent").transform; | ||
childAvatar = CreateHybridRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ChildIsAvatar(); | ||
} | ||
|
||
[Test] | ||
public void TestHybridContainsGeneric() | ||
{ | ||
parentAvatar = CreateHybridRoot("parent").transform; | ||
childAvatar = CreateGenericRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ParentIsAvatar(); | ||
} | ||
|
||
[Test] | ||
public void TestHybridContainsHybrid() | ||
{ | ||
parentAvatar = CreateHybridRoot("parent").transform; | ||
childAvatar = CreateHybridRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ParentAndChildAreAvatars(); | ||
} | ||
|
||
[Test] | ||
public void TestVRCContainsVRM0() | ||
{ | ||
parentAvatar = CreateVRCRoot("parent").transform; | ||
childAvatar = CreateVRM0Root("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ParentAndChildAreAvatars(); | ||
} | ||
|
||
[Test] | ||
public void TestVRM0ContainsVRC() | ||
{ | ||
parentAvatar = CreateVRM0Root("parent").transform; | ||
childAvatar = CreateVRCRoot("child").transform; | ||
|
||
childAvatar.parent = parentAvatar; | ||
|
||
ParentAndChildAreAvatars(); | ||
} | ||
#endif | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちらも要更新?(仮実装です)
ndmf/Editor/PreviewSystem/ComputeContext/SingleObjectQueries.cs
Lines 33 to 44 in 23fa9c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうかもしれません・・・
NDMF 1.5.0 リリース後に作業を再開する予定でしたが、この機会に全体を見直しておきます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
了解です。