Difference between revisions of "API:Layers"

From Kerbal Space Program Wiki
Jump to: navigation, search
(External views: Added more detailed explanation of mask usage.)
Line 40: Line 40:
 
===External views===
 
===External views===
 
Used for EVA or flight, without any GUI elements (layers 0, 4, 9, 10, 15 18 and 23 enabled, all others disabled).
 
Used for EVA or flight, without any GUI elements (layers 0, 4, 9, 10, 15 18 and 23 enabled, all others disabled).
 +
<code>
 +
myExternalCamera.cullingMask = (1 << 0) | (1 << 4) | (1 << 9) | (1 << 10) | (1 << 15) | (1 << 18) | (1 << 23);
 +
</code>
 +
This sets the culling mask to 100001001000011000010001, or 8,685,073 in decimal.
 +
The culling mask can also be set in decimal:
 +
<code>
 +
myExternalCamera.cullingMask = 8685073;
 +
</code>
  
<code>myExternalCamera.cullingMask = (1 << 0) | (1 << 4) | (1 << 9) | (1 << 10) | (1 << 15) | (1 << 18) | (1 << 23);</code>
 
 
This sets the culling mask to 1000 0100 1000 0110 0001 0001, or 8,685,073 in decimal.
 
  
 
===IVA===
 
===IVA===
 
Used for IVA views which can also see outside.
 
Used for IVA views which can also see outside.
 
+
<code>
<code>myInternalCamera.cullingMask = (1 << 0) | (1 << 4) | (1 << 9) | (1 << 10) | (1 << 15) | (1 << 16) | (1 << 18) | (1 << 20) | (1 << 23);</code>
+
myInternalCamera.cullingMask = (1 << 0) | (1 << 4) | (1 << 9) | (1 << 10) | (1 << 15) | (1 << 16) | (1 << 18) | (1 << 20) | (1 << 23);
 
+
</code>
 
[[Category:Community API Documentation]]
 
[[Category:Community API Documentation]]

Revision as of 14:30, 21 October 2014

Layers are used to allow cameras and lights to act only on certain parts of the scene, or to have collisions or ray casts ignore certain objects. See the Unity Layers page for more details.

Layers in KSP

There are 32 layers available. Layers 0 to 7 are reserved by Unity.

  • 0: Default (Unity built-in)
  • 1: TransparentFX (Unity built-in)
  • 2: Ignore Raycast (Unity built-in)
  • 3:
  • 4: Water (Unity built-in)
  • 5: UI (Unity built-in)
  • 6:
  • 7:
  • 8: PartsList_Icons
  • 9: Atmosphere
  • 10: Scaled Scenery
  • 11: UI_Culled
  • 12: UI_Main
  • 13: UI_Mask
  • 14: Screens
  • 15: Local Scenery
  • 16: kerbals
  • 17: Editor_UI
  • 18: SkySphere
  • 19: Disconnected Parts
  • 20: Internal Space
  • 21: Part Triggers
  • 22: KerbalInstructors
  • 23: ScaledSpaceSun
  • 24: MapFX
  • 25: EzGUI_UI
  • 26: WheelCollidersIgnore
  • 27: WheelColliders
  • 28: TerrainColliders
  • 29:
  • 30:
  • 31: Vectors

Common Camera Configurations

External views

Used for EVA or flight, without any GUI elements (layers 0, 4, 9, 10, 15 18 and 23 enabled, all others disabled). myExternalCamera.cullingMask = (1 << 0) | (1 << 4) | (1 << 9) | (1 << 10) | (1 << 15) | (1 << 18) | (1 << 23); This sets the culling mask to 100001001000011000010001, or 8,685,073 in decimal. The culling mask can also be set in decimal: myExternalCamera.cullingMask = 8685073;


IVA

Used for IVA views which can also see outside. myInternalCamera.cullingMask = (1 << 0) | (1 << 4) | (1 << 9) | (1 << 10) | (1 << 15) | (1 << 16) | (1 << 18) | (1 << 20) | (1 << 23);