根据反馈修改

This commit is contained in:
shenjianxing 2025-05-09 16:27:09 +08:00
parent 90b1694ab8
commit 17ae9098bf

View File

@ -23,8 +23,7 @@ public class Body3DObjItem : MonoBehaviour
private void Awake() private void Awake()
{ {
shader = GetComponent<Renderer>()?.material.shader;
TypeEventSystem.Global.Register<OnChangeMat>(OnChangeMatEvent).UnRegisterWhenGameObjectDestroyed(this);
#if VR #if VR
#if Turing #if Turing
@ -77,7 +76,6 @@ public class Body3DObjItem : MonoBehaviour
#endif #endif
private void OnChangeMatEvent(OnChangeMat t) private void OnChangeMatEvent(OnChangeMat t)
{ {
if (t.shader != null) if (t.shader != null)
{ {
GetComponent<Renderer>().material.shader = t.shader; GetComponent<Renderer>().material.shader = t.shader;
@ -97,7 +95,8 @@ public class Body3DObjItem : MonoBehaviour
public void Init(Body3D.Body body) public void Init(Body3D.Body body)
{ {
this.body = body; this.body = body;
shader = GetComponent<Renderer>()?.material.shader;
TypeEventSystem.Global.Register<OnChangeMat>(OnChangeMatEvent).UnRegisterWhenGameObjectDestroyed(this);
if (body.subBody == null || body.subBody.Count == 0) if (body.subBody == null || body.subBody.Count == 0)
{ {
if (body.toggle != null) if (body.toggle != null)