UniversalAdditionalCameraData.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEditor;
  5. using UnityEngine.Serialization;
  6. using UnityEngine.Assertions;
  7. namespace UnityEngine.Rendering.Universal
  8. {
  9. /// <summary>
  10. /// Holds information about whether to override certain camera rendering options from the render pipeline asset.
  11. /// When set to <c>Off</c> option will be disabled regardless of what is set on the pipeline asset.
  12. /// When set to <c>On</c> option will be enabled regardless of what is set on the pipeline asset.
  13. /// When set to <c>UsePipelineSetting</c> value set in the <see cref="UniversalRenderPipelineAsset"/>.
  14. /// </summary>
  15. public enum CameraOverrideOption
  16. {
  17. Off,
  18. On,
  19. UsePipelineSettings,
  20. }
  21. //[Obsolete("Renderer override is no longer used, renderers are referenced by index on the pipeline asset.")]
  22. public enum RendererOverrideOption
  23. {
  24. Custom,
  25. UsePipelineSettings,
  26. }
  27. /// <summary>
  28. /// Holds information about the post-processing anti-aliasing mode.
  29. /// When set to <c>None</c> no post-processing anti-aliasing pass will be performed.
  30. /// When set to <c>Fast</c> a fast approximated anti-aliasing pass will render when resolving the camera to screen.
  31. /// When set to <c>SubpixelMorphologicalAntiAliasing</c> SMAA pass will render when resolving the camera to screen. You can choose the SMAA quality by setting <seealso cref="AntialiasingQuality"/>
  32. /// </summary>
  33. public enum AntialiasingMode
  34. {
  35. [InspectorName("No Anti-aliasing")]
  36. None,
  37. [InspectorName("Fast Approximate Anti-aliasing (FXAA)")]
  38. FastApproximateAntialiasing,
  39. [InspectorName("Subpixel Morphological Anti-aliasing (SMAA)")]
  40. SubpixelMorphologicalAntiAliasing,
  41. //TemporalAntialiasing
  42. }
  43. /// <summary>
  44. /// Holds information about the render type of a camera. Options are Base or Overlay.
  45. /// Base rendering type allows the camera to render to either the screen or to a texture.
  46. /// Overlay rendering type allows the camera to render on top of a previous camera output, thus compositing camera results.
  47. /// </summary>
  48. public enum CameraRenderType
  49. {
  50. Base,
  51. Overlay,
  52. }
  53. /// <summary>
  54. /// Controls SMAA anti-aliasing quality.
  55. /// </summary>
  56. public enum AntialiasingQuality
  57. {
  58. Low,
  59. Medium,
  60. High
  61. }
  62. /// <summary>
  63. /// Contains extension methods for Camera class.
  64. /// </summary>
  65. public static class CameraExtensions
  66. {
  67. /// <summary>
  68. /// Universal Render Pipeline exposes additional rendering data in a separate component.
  69. /// This method returns the additional data component for the given camera or create one if it doesn't exist yet.
  70. /// </summary>
  71. /// <param name="camera"></param>
  72. /// <returns>The <c>UniversalAdditionalCameraData</c> for this camera.</returns>
  73. /// <see cref="UniversalAdditionalCameraData"/>
  74. public static UniversalAdditionalCameraData GetUniversalAdditionalCameraData(this Camera camera)
  75. {
  76. var gameObject = camera.gameObject;
  77. bool componentExists = gameObject.TryGetComponent<UniversalAdditionalCameraData>(out var cameraData);
  78. if (!componentExists)
  79. cameraData = gameObject.AddComponent<UniversalAdditionalCameraData>();
  80. return cameraData;
  81. }
  82. /// <summary>
  83. /// Returns the VolumeFrameworkUpdateMode set on the camera.
  84. /// </summary>
  85. /// <param name="camera"></param>
  86. /// <returns></returns>
  87. public static VolumeFrameworkUpdateMode GetVolumeFrameworkUpdateMode(this Camera camera)
  88. {
  89. UniversalAdditionalCameraData cameraData = camera.GetUniversalAdditionalCameraData();
  90. return cameraData.volumeFrameworkUpdateMode;
  91. }
  92. /// <summary>
  93. /// Sets the VolumeFrameworkUpdateMode for the camera.
  94. /// </summary>
  95. /// <param name="camera"></param>
  96. /// <param name="mode"></param>
  97. public static void SetVolumeFrameworkUpdateMode(this Camera camera, VolumeFrameworkUpdateMode mode)
  98. {
  99. UniversalAdditionalCameraData cameraData = camera.GetUniversalAdditionalCameraData();
  100. if (cameraData.volumeFrameworkUpdateMode == mode)
  101. {
  102. return;
  103. }
  104. bool requiredUpdatePreviously = cameraData.requiresVolumeFrameworkUpdate;
  105. cameraData.volumeFrameworkUpdateMode = mode;
  106. // We only update the local volume stacks for cameras set to ViaScripting.
  107. // Otherwise it will be updated in every frame.
  108. // We also check the previous value to make sure we're not updating when
  109. // switching between Camera ViaScripting and the URP Asset set to ViaScripting
  110. if (requiredUpdatePreviously && !cameraData.requiresVolumeFrameworkUpdate)
  111. {
  112. camera.UpdateVolumeStack(cameraData);
  113. }
  114. }
  115. /// <summary>
  116. /// Updates the volume stack for this camera.
  117. /// This function will only update the stack when the camera has VolumeFrameworkUpdateMode set to ViaScripting
  118. /// or when it set to UsePipelineSettings and the update mode on the Render Pipeline Asset is set to ViaScripting.
  119. /// </summary>
  120. /// <param name="camera"></param>
  121. public static void UpdateVolumeStack(this Camera camera)
  122. {
  123. UniversalAdditionalCameraData cameraData = camera.GetUniversalAdditionalCameraData();
  124. camera.UpdateVolumeStack(cameraData);
  125. }
  126. /// <summary>
  127. /// Updates the volume stack for this camera.
  128. /// This function will only update the stack when the camera has ViaScripting selected or if
  129. /// the camera is set to UsePipelineSettings and the Render Pipeline Asset is set to ViaScripting.
  130. /// </summary>
  131. /// <param name="camera"></param>
  132. /// <param name="cameraData"></param>
  133. public static void UpdateVolumeStack(this Camera camera, UniversalAdditionalCameraData cameraData)
  134. {
  135. Assert.IsNotNull(cameraData, "cameraData can not be null when updating the volume stack.");
  136. // We only update the local volume stacks for cameras set to ViaScripting.
  137. // Otherwise it will be updated in the frame.
  138. if (cameraData.requiresVolumeFrameworkUpdate)
  139. {
  140. return;
  141. }
  142. // Create stack for camera
  143. if (cameraData.volumeStack == null)
  144. {
  145. cameraData.volumeStack = VolumeManager.instance.CreateStack();
  146. }
  147. camera.GetVolumeLayerMaskAndTrigger(cameraData, out LayerMask layerMask, out Transform trigger);
  148. VolumeManager.instance.Update(cameraData.volumeStack, trigger, layerMask);
  149. }
  150. /// <summary>
  151. /// Destroys the volume stack for this camera.
  152. /// </summary>
  153. /// <param name="camera"></param>
  154. public static void DestroyVolumeStack(this Camera camera)
  155. {
  156. UniversalAdditionalCameraData cameraData = camera.GetUniversalAdditionalCameraData();
  157. camera.DestroyVolumeStack(cameraData);
  158. }
  159. /// <summary>
  160. /// Destroys the volume stack for this camera.
  161. /// </summary>
  162. /// <param name="camera"></param>
  163. /// <param name="cameraData"></param>
  164. public static void DestroyVolumeStack(this Camera camera, UniversalAdditionalCameraData cameraData)
  165. {
  166. cameraData.volumeStack.Dispose();
  167. cameraData.volumeStack = null;
  168. }
  169. /// <summary>
  170. /// Returns the mask and trigger assigned for volumes on the camera.
  171. /// </summary>
  172. /// <param name="camera"></param>
  173. /// <param name="cameraData"></param>
  174. /// <param name="layerMask"></param>
  175. /// <param name="trigger"></param>
  176. internal static void GetVolumeLayerMaskAndTrigger(this Camera camera, UniversalAdditionalCameraData cameraData, out LayerMask layerMask, out Transform trigger)
  177. {
  178. // Default values when there's no additional camera data available
  179. layerMask = 1; // "Default"
  180. trigger = camera.transform;
  181. if (cameraData != null)
  182. {
  183. layerMask = cameraData.volumeLayerMask;
  184. trigger = (cameraData.volumeTrigger != null) ? cameraData.volumeTrigger : trigger;
  185. }
  186. else if (camera.cameraType == CameraType.SceneView)
  187. {
  188. // Try to mirror the MainCamera volume layer mask for the scene view - do not mirror the target
  189. var mainCamera = Camera.main;
  190. UniversalAdditionalCameraData mainAdditionalCameraData = null;
  191. if (mainCamera != null && mainCamera.TryGetComponent(out mainAdditionalCameraData))
  192. {
  193. layerMask = mainAdditionalCameraData.volumeLayerMask;
  194. }
  195. trigger = (mainAdditionalCameraData != null && mainAdditionalCameraData.volumeTrigger != null) ? mainAdditionalCameraData.volumeTrigger : trigger;
  196. }
  197. }
  198. }
  199. static class CameraTypeUtility
  200. {
  201. static string[] s_CameraTypeNames = Enum.GetNames(typeof(CameraRenderType)).ToArray();
  202. public static string GetName(this CameraRenderType type)
  203. {
  204. int typeInt = (int)type;
  205. if (typeInt < 0 || typeInt >= s_CameraTypeNames.Length)
  206. typeInt = (int)CameraRenderType.Base;
  207. return s_CameraTypeNames[typeInt];
  208. }
  209. }
  210. [DisallowMultipleComponent]
  211. [RequireComponent(typeof(Camera))]
  212. [ImageEffectAllowedInSceneView]
  213. [URPHelpURL("universal-additional-camera-data")]
  214. public class UniversalAdditionalCameraData : MonoBehaviour, ISerializationCallbackReceiver, IAdditionalData
  215. {
  216. const string k_GizmoPath = "Packages/com.unity.render-pipelines.universal/Editor/Gizmos/";
  217. const string k_BaseCameraGizmoPath = k_GizmoPath + "Camera_Base.png";
  218. const string k_OverlayCameraGizmoPath = k_GizmoPath + "Camera_Base.png";
  219. const string k_PostProcessingGizmoPath = k_GizmoPath + "Camera_PostProcessing.png";
  220. [FormerlySerializedAs("renderShadows"), SerializeField]
  221. bool m_RenderShadows = true;
  222. [SerializeField]
  223. CameraOverrideOption m_RequiresDepthTextureOption = CameraOverrideOption.UsePipelineSettings;
  224. [SerializeField]
  225. CameraOverrideOption m_RequiresOpaqueTextureOption = CameraOverrideOption.UsePipelineSettings;
  226. [SerializeField] CameraRenderType m_CameraType = CameraRenderType.Base;
  227. [SerializeField] List<Camera> m_Cameras = new List<Camera>();
  228. [SerializeField] int m_RendererIndex = -1;
  229. [SerializeField] LayerMask m_VolumeLayerMask = 1; // "Default"
  230. [SerializeField] Transform m_VolumeTrigger = null;
  231. [SerializeField] VolumeFrameworkUpdateMode m_VolumeFrameworkUpdateModeOption = VolumeFrameworkUpdateMode.UsePipelineSettings;
  232. [SerializeField] bool m_RenderPostProcessing = false;
  233. [SerializeField] AntialiasingMode m_Antialiasing = AntialiasingMode.None;
  234. [SerializeField] AntialiasingQuality m_AntialiasingQuality = AntialiasingQuality.High;
  235. [SerializeField] bool m_StopNaN = false;
  236. [SerializeField] bool m_Dithering = false;
  237. [SerializeField] bool m_ClearDepth = true;
  238. [SerializeField] bool m_AllowXRRendering = true;
  239. [NonSerialized] Camera m_Camera;
  240. // Deprecated:
  241. [FormerlySerializedAs("requiresDepthTexture"), SerializeField]
  242. bool m_RequiresDepthTexture = false;
  243. [FormerlySerializedAs("requiresColorTexture"), SerializeField]
  244. bool m_RequiresColorTexture = false;
  245. [HideInInspector] [SerializeField] float m_Version = 2;
  246. public float version => m_Version;
  247. static UniversalAdditionalCameraData s_DefaultAdditionalCameraData = null;
  248. internal static UniversalAdditionalCameraData defaultAdditionalCameraData
  249. {
  250. get
  251. {
  252. if (s_DefaultAdditionalCameraData == null)
  253. s_DefaultAdditionalCameraData = new UniversalAdditionalCameraData();
  254. return s_DefaultAdditionalCameraData;
  255. }
  256. }
  257. #if UNITY_EDITOR
  258. internal new Camera camera
  259. #else
  260. internal Camera camera
  261. #endif
  262. {
  263. get
  264. {
  265. if (!m_Camera)
  266. {
  267. gameObject.TryGetComponent<Camera>(out m_Camera);
  268. }
  269. return m_Camera;
  270. }
  271. }
  272. /// <summary>
  273. /// Controls if this camera should render shadows.
  274. /// </summary>
  275. public bool renderShadows
  276. {
  277. get => m_RenderShadows;
  278. set => m_RenderShadows = value;
  279. }
  280. /// <summary>
  281. /// Controls if a camera should render depth.
  282. /// The depth is available to be bound in shaders as _CameraDepthTexture.
  283. /// <seealso cref="CameraOverrideOption"/>
  284. /// </summary>
  285. public CameraOverrideOption requiresDepthOption
  286. {
  287. get => m_RequiresDepthTextureOption;
  288. set => m_RequiresDepthTextureOption = value;
  289. }
  290. /// <summary>
  291. /// Controls if a camera should copy the color contents of a camera after rendering opaques.
  292. /// The color texture is available to be bound in shaders as _CameraOpaqueTexture.
  293. /// </summary>
  294. public CameraOverrideOption requiresColorOption
  295. {
  296. get => m_RequiresOpaqueTextureOption;
  297. set => m_RequiresOpaqueTextureOption = value;
  298. }
  299. /// <summary>
  300. /// Returns the camera renderType.
  301. /// <see cref="CameraRenderType"/>.
  302. /// </summary>
  303. public CameraRenderType renderType
  304. {
  305. get => m_CameraType;
  306. set => m_CameraType = value;
  307. }
  308. /// <summary>
  309. /// Returns the camera stack. Only valid for Base cameras.
  310. /// Overlay cameras have no stack and will return null.
  311. /// <seealso cref="CameraRenderType"/>.
  312. /// </summary>
  313. public List<Camera> cameraStack
  314. {
  315. get
  316. {
  317. if (renderType != CameraRenderType.Base)
  318. {
  319. var camera = gameObject.GetComponent<Camera>();
  320. Debug.LogWarning(string.Format("{0}: This camera is of {1} type. Only Base cameras can have a camera stack.", camera.name, renderType));
  321. return null;
  322. }
  323. if (scriptableRenderer.supportedRenderingFeatures.cameraStacking == false)
  324. {
  325. var camera = gameObject.GetComponent<Camera>();
  326. Debug.LogWarning(string.Format("{0}: This camera has a ScriptableRenderer that doesn't support camera stacking. Camera stack is null.", camera.name));
  327. return null;
  328. }
  329. return m_Cameras;
  330. }
  331. }
  332. internal void UpdateCameraStack()
  333. {
  334. #if UNITY_EDITOR
  335. Undo.RecordObject(this, "Update camera stack");
  336. #endif
  337. int prev = m_Cameras.Count;
  338. m_Cameras.RemoveAll(cam => cam == null);
  339. int curr = m_Cameras.Count;
  340. int removedCamsCount = prev - curr;
  341. if (removedCamsCount != 0)
  342. {
  343. Debug.LogWarning(name + ": " + removedCamsCount + " camera overlay" + (removedCamsCount > 1 ? "s" : "") + " no longer exists and will be removed from the camera stack.");
  344. }
  345. }
  346. /// <summary>
  347. /// If true, this camera will clear depth value before rendering. Only valid for Overlay cameras.
  348. /// </summary>
  349. public bool clearDepth
  350. {
  351. get => m_ClearDepth;
  352. }
  353. /// <summary>
  354. /// Returns true if this camera needs to render depth information in a texture.
  355. /// If enabled, depth texture is available to be bound and read from shaders as _CameraDepthTexture after rendering skybox.
  356. /// </summary>
  357. public bool requiresDepthTexture
  358. {
  359. get
  360. {
  361. if (m_RequiresDepthTextureOption == CameraOverrideOption.UsePipelineSettings)
  362. {
  363. return UniversalRenderPipeline.asset.supportsCameraDepthTexture;
  364. }
  365. else
  366. {
  367. return m_RequiresDepthTextureOption == CameraOverrideOption.On;
  368. }
  369. }
  370. set { m_RequiresDepthTextureOption = (value) ? CameraOverrideOption.On : CameraOverrideOption.Off; }
  371. }
  372. /// <summary>
  373. /// Returns true if this camera requires to color information in a texture.
  374. /// If enabled, color texture is available to be bound and read from shaders as _CameraOpaqueTexture after rendering skybox.
  375. /// </summary>
  376. public bool requiresColorTexture
  377. {
  378. get
  379. {
  380. if (m_RequiresOpaqueTextureOption == CameraOverrideOption.UsePipelineSettings)
  381. {
  382. return UniversalRenderPipeline.asset.supportsCameraOpaqueTexture;
  383. }
  384. else
  385. {
  386. return m_RequiresOpaqueTextureOption == CameraOverrideOption.On;
  387. }
  388. }
  389. set { m_RequiresOpaqueTextureOption = (value) ? CameraOverrideOption.On : CameraOverrideOption.Off; }
  390. }
  391. /// <summary>
  392. /// Returns the <see cref="ScriptableRenderer"/> that is used to render this camera.
  393. /// </summary>
  394. public ScriptableRenderer scriptableRenderer
  395. {
  396. get
  397. {
  398. if (UniversalRenderPipeline.asset is null)
  399. return null;
  400. if (!UniversalRenderPipeline.asset.ValidateRendererData(m_RendererIndex))
  401. {
  402. int defaultIndex = UniversalRenderPipeline.asset.m_DefaultRendererIndex;
  403. Debug.LogWarning(
  404. $"Renderer at <b>index {m_RendererIndex.ToString()}</b> is missing for camera <b>{camera.name}</b>, falling back to Default Renderer. <b>{UniversalRenderPipeline.asset.m_RendererDataList[defaultIndex].name}</b>",
  405. UniversalRenderPipeline.asset);
  406. return UniversalRenderPipeline.asset.GetRenderer(defaultIndex);
  407. }
  408. return UniversalRenderPipeline.asset.GetRenderer(m_RendererIndex);
  409. }
  410. }
  411. /// <summary>
  412. /// Use this to set this Camera's current <see cref="ScriptableRenderer"/> to one listed on the Render Pipeline Asset. Takes an index that maps to the list on the Render Pipeline Asset.
  413. /// </summary>
  414. /// <param name="index">The index that maps to the RendererData list on the currently assigned Render Pipeline Asset</param>
  415. public void SetRenderer(int index)
  416. {
  417. m_RendererIndex = index;
  418. }
  419. /// <summary>
  420. /// Returns the selected scene-layers affecting this camera.
  421. /// </summary>
  422. public LayerMask volumeLayerMask
  423. {
  424. get => m_VolumeLayerMask;
  425. set => m_VolumeLayerMask = value;
  426. }
  427. /// <summary>
  428. /// Returns the Transform that acts as a trigger for Volume blending.
  429. /// </summary>
  430. public Transform volumeTrigger
  431. {
  432. get => m_VolumeTrigger;
  433. set => m_VolumeTrigger = value;
  434. }
  435. /// <summary>
  436. /// Returns the selected mode for Volume Frame Updates.
  437. /// </summary>
  438. internal VolumeFrameworkUpdateMode volumeFrameworkUpdateMode
  439. {
  440. get => m_VolumeFrameworkUpdateModeOption;
  441. set => m_VolumeFrameworkUpdateModeOption = value;
  442. }
  443. /// <summary>
  444. /// Returns true if this camera requires the volume framework to be updated every frame.
  445. /// </summary>
  446. public bool requiresVolumeFrameworkUpdate
  447. {
  448. get
  449. {
  450. if (m_VolumeFrameworkUpdateModeOption == VolumeFrameworkUpdateMode.UsePipelineSettings)
  451. {
  452. return UniversalRenderPipeline.asset.volumeFrameworkUpdateMode != VolumeFrameworkUpdateMode.ViaScripting;
  453. }
  454. return m_VolumeFrameworkUpdateModeOption == VolumeFrameworkUpdateMode.EveryFrame;
  455. }
  456. }
  457. /// <summary>
  458. /// Returns the current volume stack used by this camera.
  459. /// </summary>
  460. VolumeStack m_VolumeStack = null;
  461. public VolumeStack volumeStack
  462. {
  463. get => m_VolumeStack;
  464. set => m_VolumeStack = value;
  465. }
  466. /// <summary>
  467. /// Returns true if this camera should render post-processing.
  468. /// </summary>
  469. public bool renderPostProcessing
  470. {
  471. get => m_RenderPostProcessing;
  472. set => m_RenderPostProcessing = value;
  473. }
  474. /// <summary>
  475. /// Returns the current anti-aliasing mode used by this camera.
  476. /// <see cref="AntialiasingMode"/>.
  477. /// </summary>
  478. public AntialiasingMode antialiasing
  479. {
  480. get => m_Antialiasing;
  481. set => m_Antialiasing = value;
  482. }
  483. /// <summary>
  484. /// Returns the current anti-aliasing quality used by this camera.
  485. /// <seealso cref="antialiasingQuality"/>.
  486. /// </summary>
  487. public AntialiasingQuality antialiasingQuality
  488. {
  489. get => m_AntialiasingQuality;
  490. set => m_AntialiasingQuality = value;
  491. }
  492. /// <summary>
  493. /// Returns true if this camera should automatically replace NaN/Inf in shaders by a black pixel to avoid breaking some effects.
  494. /// </summary>
  495. public bool stopNaN
  496. {
  497. get => m_StopNaN;
  498. set => m_StopNaN = value;
  499. }
  500. /// <summary>
  501. /// Returns true if this camera applies 8-bit dithering to the final render to reduce color banding
  502. /// </summary>
  503. public bool dithering
  504. {
  505. get => m_Dithering;
  506. set => m_Dithering = value;
  507. }
  508. /// <summary>
  509. /// Returns true if this camera allows render in XR.
  510. /// </summary>
  511. public bool allowXRRendering
  512. {
  513. get => m_AllowXRRendering;
  514. set => m_AllowXRRendering = value;
  515. }
  516. public void OnBeforeSerialize()
  517. {
  518. }
  519. public void OnAfterDeserialize()
  520. {
  521. if (version <= 1)
  522. {
  523. m_RequiresDepthTextureOption = (m_RequiresDepthTexture) ? CameraOverrideOption.On : CameraOverrideOption.Off;
  524. m_RequiresOpaqueTextureOption = (m_RequiresColorTexture) ? CameraOverrideOption.On : CameraOverrideOption.Off;
  525. }
  526. }
  527. public void OnDrawGizmos()
  528. {
  529. string gizmoName = "";
  530. Color tint = Color.white;
  531. if (m_CameraType == CameraRenderType.Base)
  532. {
  533. gizmoName = k_BaseCameraGizmoPath;
  534. }
  535. else if (m_CameraType == CameraRenderType.Overlay)
  536. {
  537. gizmoName = k_OverlayCameraGizmoPath;
  538. }
  539. #if UNITY_2019_2_OR_NEWER
  540. #if UNITY_EDITOR
  541. if (Selection.activeObject == gameObject)
  542. {
  543. // Get the preferences selection color
  544. tint = SceneView.selectedOutlineColor;
  545. }
  546. #endif
  547. if (!string.IsNullOrEmpty(gizmoName))
  548. {
  549. Gizmos.DrawIcon(transform.position, gizmoName, true, tint);
  550. }
  551. if (renderPostProcessing)
  552. {
  553. Gizmos.DrawIcon(transform.position, k_PostProcessingGizmoPath, true, tint);
  554. }
  555. #else
  556. if (renderPostProcessing)
  557. {
  558. Gizmos.DrawIcon(transform.position, k_PostProcessingGizmoPath);
  559. }
  560. Gizmos.DrawIcon(transform.position, gizmoName);
  561. #endif
  562. }
  563. }
  564. }