5 namespace droid.Runtime.Utilities.GameObjects.NeodroidCamera {
9 [RequireComponent(typeof(Camera))]
21 bool _run_only_in_edit_mode =
true;
26 bool _only_run_on_awake =
false;
31 bool _sync_culling_mask =
true;
36 bool _sync_far_clip_plane =
true;
41 bool _sync_fov =
true;
46 bool _sync_near_clip_plane =
true;
51 bool _sync_orthographic_projection =
true;
56 bool _sync_orthographic_size =
true;
61 bool _sync_physicality =
true;
66 bool _sync_sensor_size =
true;
71 bool _sync_lens_shift =
true;
76 bool _sync_gate_fit =
true;
81 bool _sync_focal_length =
true;
94 [SerializeField] Camera _camera;
98 int _old_culling_mask = 0;
100 float _old_far_clip_plane = 0;
104 float _old_near_clip_plane = 0;
106 bool _old_orthographic_projection =
false;
108 float _old_orthographic_size = 0;
111 bool _old_physicality =
false;
112 Camera.GateFitMode _old_gate_fit = Camera.GateFitMode.Fill;
113 Vector2 _old_sensor_size = Vector2.one;
114 Vector2 _old_lens_shift = Vector2.zero;
122 get {
return this._camera.focalLength; }
124 if (this._sync_focal_length) {
125 this._camera.focalLength = value;
126 this._old_foc = value;
134 public float OrtSize {
135 get {
return this._camera.orthographicSize; }
137 if (this._sync_orthographic_size) {
138 this._camera.orthographicSize = value;
139 this._old_orthographic_size = value;
148 get {
return this._camera.nearClipPlane; }
150 if (this._sync_far_clip_plane) {
151 this._camera.nearClipPlane = value;
152 this._old_near_clip_plane = value;
158 get {
return this._camera.fieldOfView; }
160 if (this._sync_fov) {
161 this._camera.fieldOfView = value;
162 this._old_fov = value;
168 get {
return this._camera.orthographic; }
170 if (this._sync_orthographic_projection) {
171 this._camera.orthographic = value;
172 this._old_orthographic_projection = value;
178 get {
return this._camera.cullingMask; }
180 if (this._sync_culling_mask) {
181 this._camera.cullingMask = value;
182 this._old_culling_mask = value;
188 get {
return this._camera.farClipPlane; }
190 if (this._sync_far_clip_plane) {
191 this._camera.farClipPlane = value;
192 this._old_far_clip_plane = value;
197 public bool Physicality {
198 get {
return this._camera.usePhysicalProperties; }
200 if (this._sync_physicality) {
201 this._camera.usePhysicalProperties = value;
202 this._old_physicality = value;
207 public Camera.GateFitMode Gate {
208 get {
return this._camera.gateFit; }
210 if (this._sync_gate_fit) {
211 this._camera.gateFit = value;
212 this._old_gate_fit = value;
217 public Vector2 SensSize {
218 get {
return this._camera.sensorSize; }
220 if (this._sync_sensor_size) {
221 this._camera.sensorSize = value;
222 this._old_sensor_size = value;
227 public Vector2 Shift {
228 get {
return this._camera.lensShift; }
230 if (this._sync_lens_shift) {
231 this._camera.lensShift = value;
232 this._old_lens_shift = value;
240 this._camera = this.GetComponent<Camera>();
242 this.OrtSize = this._camera.orthographicSize;
243 this.Near = this._camera.nearClipPlane;
244 this.Far = this._camera.farClipPlane;
245 this.Mask = this._camera.cullingMask;
246 this.Ort = this._camera.orthographic;
247 this.Fov = this._camera.fieldOfView;
248 this.Foc = this._camera.focalLength;
249 this.Physicality = this._camera.usePhysicalProperties;
250 this.Gate = this._camera.gateFit;
251 this.SensSize = this._camera.sensorSize;
252 this.Shift = this._camera.lensShift;
254 this._cameras = FindObjectsOfType<SynchroniseCameraProperties>();
256 Debug.Log(
"No camera component found on GameObject");
265 if (this._sync_orthographic_size) {
266 var orthographic_size = this.OrtSize;
267 if (Math.Abs(
this._old_orthographic_size - orthographic_size)
268 > NeodroidConstants._Double_Tolerance) {
269 this.OrtSize = orthographic_size;
270 foreach (var cam
in this._cameras) {
271 if (cam !=
this && cam != null) {
272 cam.OrtSize = orthographic_size;
278 if (this._sync_near_clip_plane) {
279 var near_clip_plane = this._camera.nearClipPlane;
280 if (Math.Abs(
this._old_near_clip_plane - near_clip_plane) > NeodroidConstants._Double_Tolerance) {
281 this._old_near_clip_plane = near_clip_plane;
282 foreach (var cam
in this._cameras) {
283 if (cam !=
this && cam != null) {
284 cam.Near = near_clip_plane;
290 if (this._sync_far_clip_plane) {
291 var far_clip_plane = this._camera.farClipPlane;
292 if (Math.Abs(
this._old_far_clip_plane - far_clip_plane) > NeodroidConstants._Double_Tolerance) {
293 this._old_far_clip_plane = far_clip_plane;
294 foreach (var cam
in this._cameras) {
295 if (cam !=
this && cam != null) {
296 cam.Far = far_clip_plane;
302 if (this._sync_culling_mask) {
303 var culling_mask = this._camera.cullingMask;
304 if (this._old_culling_mask != culling_mask) {
305 this._old_culling_mask = culling_mask;
306 foreach (var cam
in this._cameras) {
307 if (cam !=
this && cam != null) {
308 cam.Mask = culling_mask;
313 if (this._sync_orthographic_projection) {
314 var orthographic = this._camera.orthographic;
315 if (this._old_orthographic_projection != orthographic) {
316 this._old_orthographic_projection = orthographic;
317 foreach (var cam
in this._cameras) {
318 if (cam !=
this && cam != null) {
319 cam.Ort = orthographic;
326 if (this._sync_fov) {
327 var fov = this._camera.fieldOfView;
328 if (Math.Abs(
this._old_fov - fov) > NeodroidConstants._Double_Tolerance) {
330 foreach (var cam
in this._cameras) {
331 if (cam !=
this && cam != null) {
338 if (this._sync_focal_length) {
339 var foc = this._camera.focalLength;
340 if (Math.Abs(
this._old_foc - foc) > NeodroidConstants._Double_Tolerance) {
342 foreach (var cam
in this._cameras) {
343 if (cam !=
this && cam != null) {
350 if (this._sync_physicality) {
351 var physicality = this._camera.usePhysicalProperties;
352 if (this._old_physicality != physicality) {
353 this._old_physicality = physicality;
354 foreach (var cam
in this._cameras) {
355 if (cam !=
this && cam != null) {
356 cam.Physicality = physicality;
362 if (this._sync_sensor_size) {
363 var a = this._camera.sensorSize;
364 if (this._old_sensor_size != a) {
365 this._old_sensor_size = a;
366 foreach (var cam
in this._cameras) {
367 if (cam !=
this && cam != null) {
374 if (this._sync_lens_shift) {
375 var a = this._camera.lensShift;
376 if (this._old_lens_shift != a) {
377 this._old_lens_shift = a;
378 foreach (var cam
in this._cameras) {
379 if (cam !=
this && cam != null) {
386 if (this._sync_gate_fit) {
387 var a = this._camera.gateFit;
388 if (this._old_gate_fit != a) {
389 this._old_gate_fit = a;
390 foreach (var cam
in this._cameras) {
391 if (cam !=
this && cam != null) {
399 Debug.Log($
"No Camera component found on {this.name} GameObject");
414 if (!this._only_run_on_awake) {
415 if (this._run_only_in_edit_mode) {
417 if (!Application.isPlaying) {