powerfun-unity/Assets/AR/BaseRenderer.cs

81 lines
2.2 KiB
C#

using System.Runtime.InteropServices;
using UnityEngine;
namespace Assets.AR
{
public abstract class BaseRenderer : ARLaneObject
{
protected Animator animator;
protected Shader shaderNormal;
protected Shader shaderAplha;
protected MaterialPropertyBlock materialPropertyBlock;
private bool paused = true;
public bool Male { get; protected set; }
public Texture2D JerseyTexture { get; set; }
public Color ColorSkin { get; set; }
public Color ColorUser { get; set; }
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.shaderAplha = Shader.Find("Rouvy/RiderShaderOneAlpha");
//this.shaderNormal = Shader.Find("Rouvy/RiderShaderOne");
this.materialPropertyBlock = new MaterialPropertyBlock();
}
public void Initialize(bool male) => this.Male = male;
protected virtual void Start()
{
this.SetupModels();
this.SetLayerRecursively(this.gameObject, 9);
this.animator.avatar = (Avatar)null;
}
protected override void Update()
{
base.Update();
}
protected abstract void SetupModels();
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);
}
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct ShaderID
{
public static int mainTex = Shader.PropertyToID("_MainTex");
public static int opacity = Shader.PropertyToID("_Opacity");
public static int colorCustom = Shader.PropertyToID("_ColorCustom");
}
}
}