39 lines
933 B
C#
39 lines
933 B
C#
using QFramework;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using XMLTool;
|
|
|
|
public class LineModeItem : MonoBehaviour
|
|
{
|
|
Shader shader;
|
|
public Body3D.Body body;
|
|
public LineModeItem Init(Body3D.Body body)
|
|
{
|
|
this.body = body;
|
|
shader = GetComponent<Renderer>()?.material.shader;
|
|
TypeEventSystem.Global.Register<OnChangeMat>(OnChangeMatEvent).UnRegisterWhenGameObjectDestroyed(this);
|
|
return this;
|
|
}
|
|
|
|
|
|
private void OnChangeMatEvent(OnChangeMat t)
|
|
{
|
|
if (t.shader != null)
|
|
{
|
|
GetComponent<Renderer>().material.shader = t.shader;
|
|
if (body.lineModeWidth != 0)
|
|
{
|
|
GetComponent<Renderer>().material.SetFloat("_OutlineWidth", body.lineModeWidth);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
GetComponent<Renderer>().material.shader = this.shader;
|
|
}
|
|
|
|
}
|
|
|
|
}
|