Skip to content

Commit

Permalink
BoxMan use custom material
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Feb 3, 2025
1 parent a1e5c85 commit 647f5c0
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IVrm10Animation : IDisposable
(INormalizedPoseProvider, ITPoseProvider) ControlRig { get; }
IReadOnlyDictionary<ExpressionKey, Func<float>> ExpressionMap { get; }
public void ShowBoxMan(bool enable);
public void SetBoxManMaterial(Material material);
LookAtInput? LookAt { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public void ShowBoxMan(bool enable)
BoxMan.enabled = enable;
}

public void SetBoxManMaterial(Material material)
{
BoxMan.material = material;
}

public void Dispose()
{
if (Application.isPlaying)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,9 @@ public void Dispose()
public void ShowBoxMan(bool enable)
{
}

public void SetBoxManMaterial(Material material)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public void ShowBoxMan(bool enable)
m_boxMan.enabled = enable;
}

public void SetBoxManMaterial(Material material)
{
}

public void Dispose()
{
GameObject.Destroy(m_context.Root);
Expand Down
5 changes: 5 additions & 0 deletions Assets/VRM10_Samples/VRM10Viewer/Motions/BvhMotion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public void ShowBoxMan(bool enable)
m_boxMan.enabled = enable;
}

public void SetBoxManMaterial(Material material)
{
m_boxMan.material = material;
}

public void Dispose()
{
GameObject.Destroy(m_context.Root);
Expand Down
4 changes: 4 additions & 0 deletions Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity
Original file line number Diff line number Diff line change
Expand Up @@ -4736,6 +4736,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_primitiveType: 4
_urpMaterial: {fileID: -876546973899608171, guid: ac58f8c11a130e04ba883a82ae4b78e4,
type: 3}
--- !u!1 &325720722
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -13430,6 +13432,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_primitiveType: 0
_urpMaterial: {fileID: -876546973899608171, guid: ac58f8c11a130e04ba883a82ae4b78e4,
type: 3}
--- !u!1 &806723448
GameObject:
m_ObjectHideFlags: 0
Expand Down
4 changes: 4 additions & 0 deletions Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ private void Start()
if (m_motion != null)
{
Motion = BvhMotion.LoadBvhFromText(m_motion.text);
if (m_useCustomMaterial.isOn)
{
Motion.SetBoxManMaterial(Instantiate(m_customMaterial));
}
}

if (ArgumentChecker.TryGetFirstLoadable(out var cmd))
Expand Down
10 changes: 10 additions & 0 deletions Assets/VRM10_Samples/VRM10Viewer/VRM10VisualPrimitive.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using UnityEngine.Rendering;

namespace UniVRM10.VRM10Viewer
{
Expand All @@ -9,6 +10,8 @@ public class VRM10VisualPrimitive : MonoBehaviour
{
[SerializeField] private PrimitiveType _primitiveType;

[SerializeField] private Material _urpMaterial;

public PrimitiveType PrimitiveType
{
get => _primitiveType;
Expand All @@ -22,6 +25,13 @@ private void Start()
visual.transform.localPosition = Vector3.zero;
visual.transform.localRotation = Quaternion.identity;
visual.transform.localScale = Vector3.one;
if (Application.platform == RuntimePlatform.WebGLPlayer || GraphicsSettings.renderPipelineAsset != null)
{
if (_urpMaterial != null)
{
visual.GetComponent<Renderer>().material = Instantiate(_urpMaterial);
}
}
}

void OnDrawGizmos()
Expand Down

0 comments on commit 647f5c0

Please sign in to comment.