powerfun-unity/Assets/AR/AbstractRenderer.cs

59 lines
1.4 KiB
C#
Raw Permalink Normal View History

2022-11-25 19:18:21 +08:00
using System.Runtime.InteropServices;
using UnityEngine;
namespace Assets.AR
{
2023-01-31 18:22:15 +08:00
public abstract class AbstractRenderer : ARLaneGameObject
2022-11-25 19:18:21 +08:00
{
protected Animator animator;
2023-04-18 17:10:48 +08:00
2022-11-25 19:18:21 +08:00
protected MaterialPropertyBlock materialPropertyBlock;
2023-04-18 17:10:48 +08:00
2022-11-25 19:18:21 +08:00
private bool paused = true;
public bool Male { get; protected set; }
2023-04-18 17:10:48 +08:00
2022-11-25 19:18:21 +08:00
public bool Paused
{
get => this.paused;
set
{
if (value == this.paused)
return;
this.paused = value;
this.OnPause(this.paused);
}
}
protected override void Awake()
{
base.Awake();
this.animator = this.GetComponent<Animator>();
this.materialPropertyBlock = new MaterialPropertyBlock();
}
public void Initialize(bool male) => this.Male = male;
protected virtual void Start()
{
2023-04-18 17:10:48 +08:00
this.animator.avatar = null;
2022-11-25 19:18:21 +08:00
}
protected override void Update()
{
base.Update();
}
protected virtual void OnPause(bool paused)
{
}
protected void SetLayerRecursively(GameObject obj, int layer)
{
obj.layer = layer;
foreach (Component component in obj.transform)
this.SetLayerRecursively(component.gameObject, layer);
}
}
}