Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
ReplacementShaderEffect.cs
Go to the documentation of this file.
1 using UnityEngine;
2 
3 namespace droid.Runtime.Utilities.GameObjects.NeodroidCamera {
7  [ExecuteInEditMode]
8  public class ReplacementShaderEffect : MonoBehaviour {
9  //[SerializeField] Color _color = Color.gray;
10  //[SerializeField] Color _outline_color = Color.magenta;
11  //[SerializeField, Range(0, 1)] float _outline_width_factor = 0.3f;
12  [SerializeField] string _replace_render_type = "";
13 
14  [SerializeField] Shader _replacement_shader = null;
15  //[SerializeField, Range(0, 1)] int _use_right;
16  //[SerializeField, Range(0.001f, 1000f)] float _scalar = 0.01f;
17  //static readonly Int32 _scalar1 = Shader.PropertyToID("_Scalar");
18 
19  void OnValidate() { this.Setup(); }
20 
21  void OnEnable() {
22  if (this._replacement_shader != null) {
23  this.GetComponent<Camera>().SetReplacementShader(this._replacement_shader, this._replace_render_type);
24  }
25  }
26 
27  void Setup() {
28  //Shader.SetGlobalColor("_SegmentationColor", this._color);
29  //Shader.SetGlobalColor ("_OutlineColor", this._outline_color);
30  //Shader.SetGlobalFloat("_OutlineWidthFactor", this._outline_width_factor);
31  //Shader.SetGlobalFloat("_UseRight", this._use_right);
32  //Shader.SetGlobalFloat(_scalar1, this._scalar);
33  }
34 
35  void OnDisable() { this.GetComponent<Camera>().ResetReplacementShader(); }
36 
37  void OnPreRender() { }
38  }
39 }