2 using System.Collections.Generic;
6 namespace droid.Runtime.Utilities.GameObjects.NeodroidCamera.Segmentation.Obsolete {
14 Renderer[] _all_renders;
18 MaterialPropertyBlock _block;
27 LinkedList<Color>[] _original_colors;
31 public bool _Replace_Untagged_Color =
true;
33 [SerializeField] ScriptableObjects.Segmentation _segmentation = null;
37 Dictionary<string, Color> _tag_colors_dict =
new Dictionary<string, Color>();
41 public Color _Untagged_Color = Color.black;
45 public ColorByCategory[] ColorsByCategory {
get {
return this._colors_by_category; } }
49 public override Dictionary<String, Color> ColorsDict {
get {
return this._tag_colors_dict; } }
54 this._block =
new MaterialPropertyBlock();
55 this._tag_colors_dict.Clear();
56 var colors_by_tag = this._colors_by_category;
57 if (colors_by_tag != null && colors_by_tag.Length > 0) {
58 foreach (var tag_color
in this._colors_by_category) {
59 if (!this._tag_colors_dict.ContainsKey(tag_color._Category_Name)) {
60 this._tag_colors_dict.Add(tag_color._Category_Name, tag_color._Color);
65 if (this._segmentation) {
66 var segmentation_color_by_tags = this._segmentation._color_by_categories;
67 if (segmentation_color_by_tags != null) {
68 foreach (var tag_color
in segmentation_color_by_tags) {
69 if (!this._tag_colors_dict.ContainsKey(tag_color._Category_Name)) {
70 this._tag_colors_dict.Add(tag_color._Category_Name, tag_color._Color);
90 this._all_renders = FindObjectsOfType<Renderer>();
96 this._original_colors =
new LinkedList<Color>[this._all_renders.Length];
97 for (var i = 0; i < this._original_colors.Length; i++) {
98 this._original_colors[i] =
new LinkedList<Color>();
103 for (var i = 0; i < this._all_renders.Length; i++) {
104 var c_renderer = this._all_renders[i];
106 if (this._tag_colors_dict != null && this._tag_colors_dict.ContainsKey(
this._all_renders[i].tag)) {
107 foreach (var mat
in this._all_renders[i].sharedMaterials) {
108 if (mat != null && mat.HasProperty(
this._Default_Color_Tag)) {
109 this._original_colors[i].AddFirst(mat.color);
112 this._block.SetColor(this._Segmentation_Color_Tag,
113 this._tag_colors_dict[this._all_renders[i].tag]);
115 this._block.SetColor(this._Outline_Color_Tag, this._Outline_Color);
116 this._block.SetFloat(this._Outline_Width_Factor_Tag, this._Outline_Width_Factor);
117 this._all_renders[i].SetPropertyBlock(this._block);
119 }
else if (this._Replace_Untagged_Color) {
120 foreach (var mat
in this._all_renders[i].sharedMaterials) {
121 if (mat != null && mat.HasProperty(
this._Default_Color_Tag)) {
122 this._original_colors[i].AddFirst(mat.color);
125 this._block.SetColor(this._Segmentation_Color_Tag, this._Untagged_Color);
127 this._block.SetColor(this._Outline_Color_Tag, this._Outline_Color);
128 this._block.SetFloat(this._Outline_Width_Factor_Tag, this._Outline_Width_Factor);
129 this._all_renders[i].SetPropertyBlock(this._block);
137 if (this._block == null) {
138 this._block =
new MaterialPropertyBlock();
147 for (var i = 0; i < this._all_renders.Length; i++) {
148 if (this._all_renders[i]) {
149 foreach (var mat
in this._all_renders[i].sharedMaterials) {
150 if (mat != null && this._original_colors != null && i < this._original_colors.Length) {
151 var c = this._original_colors[i];
154 var last_val = last.Value;
155 this._block.SetColor(this._Default_Color_Tag, last_val);
156 this._original_colors[i].RemoveLast();
157 this._all_renders[i].SetPropertyBlock(this._block);
ColorByCategory [] _colors_by_category