Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
CameraObservationTextureController.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
4 using UnityEngine;
5 
6 namespace droid.Runtime.Utilities.GameObjects.NeodroidCamera {
10  [ExecuteInEditMode]
11  [Serializable]
12  public class CameraObservationTextureController : MonoBehaviour {
13  [SerializeField] Camera[] _cameras = null;
14  [SerializeField] FilterMode _filter_mode = FilterMode.Bilinear;
15 
16  [SerializeField]
17  Vector2Int _size = new Vector2Int(NeodroidConstants._Default_Observation_Texture_Xy_Size,
18  NeodroidConstants._Default_Observation_Texture_Xy_Size);
19  //[SerializeField] GraphicsFormat _texture_format = GraphicsFormat.R8G8B8A8_UNorm;
20 
21  [SerializeField] Texture[] _textures = null;
22  [SerializeField] TextureWrapMode _wrap_mode = TextureWrapMode.Clamp;
23 
24  void Awake() {
25  this._cameras = FindObjectsOfType<Camera>();
26 
27  var textures = new List<Texture>();
28 
29  foreach (var a_camera in this._cameras) {
30  var target = a_camera.targetTexture;
31  if (target) {
32  textures.Add(target);
33  }
34  }
35 
36  this._textures = textures.ToArray();
37 
38  foreach (var texture in this._textures) {
39  if (texture) {
40  //texture.height = this._size.y;
41  //texture.width = this._size.x;
42  texture.filterMode = this._filter_mode;
43  texture.wrapMode = this._wrap_mode;
44  //texture.graphicsFormat = this._texture_format;
45  }
46  }
47  }
48  }
49 }