Kerbal Space Program
1.12.4
|
SoftMask is a component that can be added to UI elements for masking the children. It works like a standard Unity's Mask but supports alpha. More...
Public Types | |
enum | BorderMode { BorderMode.Simple, BorderMode.Sliced, BorderMode.Tiled } |
How Sprite's borders should be processed. It is a reduced set of Image.Type values. More... | |
enum | Errors { Errors.NoError = 0, Errors.UnsupportedShaders = 1 << 0, Errors.NestedMasks = 1 << 1, Errors.TightPackedSprite = 1 << 2, Errors.AlphaSplitSprite = 1 << 3, Errors.UnsupportedImageType = 1 << 4, Errors.UnreadableTexture = 1 << 5 } |
Errors encountered during SoftMask diagnostics. Mostly intended to use in Unity Editor. More... | |
enum | MaskSource { MaskSource.Graphic, MaskSource.Sprite, MaskSource.Texture } |
Source of the mask's image. More... | |
Public Member Functions | |
bool | IsRaycastLocationValid (Vector2 sp, Camera cam) |
Errors | PollErrors () |
Checks for errors and returns them as flags. It is used in the editor to determine which warnings should be displayed. More... | |
SoftMask () | |
Protected Member Functions | |
virtual void | LateUpdate () |
override void | OnCanvasHierarchyChanged () |
override void | OnDestroy () |
override void | OnDidApplyAnimationProperties () |
override void | OnDisable () |
override void | OnEnable () |
override void | OnRectTransformDimensionsChange () |
override void | OnTransformParentChanged () |
override void | Start () |
Properties | |
Color | channelWeights [get, set] |
Specifies weights of the color channels of the mask. The color sampled from the mask texture is multiplied by this value, after what all components are summed up together. That is, the final mask value is calculated as: color = pixel-from-mask * channelWeights value = color.r + color.g + color.b + color.a The value is a number by which the resulting pixel's alpha is multiplied. As you can see, the result value isn't normalized, so, you should account it while defining custom values for this property. Static class MaskChannel contains some useful predefined values. You can use they as example of how mask calculation works. The default value is MaskChannel.alpha. More... | |
Shader | defaultETC1Shader [get, set] |
Specifies a Shader that should be used as a replacement of the Unity's default UI shader with ETC1 (alpha-split) support. If you use ETC1 textures in UI and add SoftMask in play-time by AddComponent(), you should set this property manually. More... | |
Shader | defaultShader [get, set] |
Specifies a Shader that should be used as a replacement of the Unity's default UI shader. If you add SoftMask in play-time by AddComponent(), you should set this property manually. More... | |
bool | invertMask [get, set] |
If set, mask values inside the mask rectangle will be inverted. In this case mask's zero value (taking channelWeights into account) will be treated as one and vice versa. The mask rectangle is the RectTransform of the GameObject this component is attached to or separateMask if it's not null. The default value is false. More... | |
bool | invertOutsides [get, set] |
If set, mask values outside the mask rectangle will be inverted. By default, everything outside the mask rectangle has zero mask value. When this property is set, the mask outsides will have value one, which means that everything outside the mask will be visible. The mask rectangle is the RectTransform of the GameObject this component is attached to or separateMask if it's not null. The default value is false. More... | |
bool | isMaskingEnabled [get] |
Returns true if masking is currently active. More... | |
bool | isUsingRaycastFiltering [get] |
Returns true if Soft Mask does raycast filtering, that is if the masked areas are transparent to input. More... | |
float | raycastThreshold [get, set] |
Specifies the minimum mask value that the point should have for an input event to pass. If the value sampled from the mask is greater or equal this value, the input event is considered 'hit'. The mask value is compared with raycastThreshold after channelWeights applied. The default value is 0, which means that any pixel belonging to RectTransform is considered in input events. If you specify the value greater than 0, the mask's texture should be readable. Accepts values in range [0..1]. More... | |
RectTransform | separateMask [get, set] |
Specifies a RectTransform that defines the bounds of the mask. Use of a separate RectTransform allows to move or resize mask bounds not affecting children. When null, the RectTransform of the current object is used. Default value is null. More... | |
MaskSource | source [get, set] |
Determines from where the mask image should be taken. More... | |
Sprite | sprite [get, set] |
Specifies a Sprite that should be used as the mask image. This property takes effect only when the source is MaskSource.Sprite. More... | |
BorderMode | spriteBorderMode [get, set] |
Specifies the draw mode of sprite borders. This property takes effect only when the source is MaskSource.Sprite. More... | |
Texture2D | texture [get, set] |
Specifies a Texture2D that should be used as the mask image. This property takes effect only when the source is MaskSource.Texture. More... | |
Rect | textureUVRect [get, set] |
Specifies a normalized UV-space rectangle defining the image part that should be used as the mask image. This property takes effect only when the source is MaskSource.Texture. A value is set in normalized coordinates. The default value is (0, 0, 1, 1), which means that the whole texture is used. More... | |
Properties inherited from SoftMasking.ISoftMask | |
bool | isAlive [get] |
bool | isMaskingEnabled [get] |
SoftMask is a component that can be added to UI elements for masking the children. It works like a standard Unity's Mask but supports alpha.
How Sprite's borders should be processed. It is a reduced set of Image.Type values.
Source of the mask's image.
|
inline |
|
inline |
|
inlineprotectedvirtual |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
Checks for errors and returns them as flags. It is used in the editor to determine which warnings should be displayed.
|
inlineprotected |
|
getset |
Specifies weights of the color channels of the mask. The color sampled from the mask texture is multiplied by this value, after what all components are summed up together. That is, the final mask value is calculated as: color = pixel-from-mask
* channelWeights value = color.r + color.g + color.b + color.a The value
is a number by which the resulting pixel's alpha is multiplied. As you can see, the result value isn't normalized, so, you should account it while defining custom values for this property. Static class MaskChannel contains some useful predefined values. You can use they as example of how mask calculation works. The default value is MaskChannel.alpha.
|
getset |
Specifies a Shader that should be used as a replacement of the Unity's default UI shader with ETC1 (alpha-split) support. If you use ETC1 textures in UI and add SoftMask in play-time by AddComponent(), you should set this property manually.
|
getset |
Specifies a Shader that should be used as a replacement of the Unity's default UI shader. If you add SoftMask in play-time by AddComponent(), you should set this property manually.
|
getset |
If set, mask values inside the mask rectangle will be inverted. In this case mask's zero value (taking channelWeights into account) will be treated as one and vice versa. The mask rectangle is the RectTransform of the GameObject this component is attached to or separateMask if it's not null. The default value is false.
|
getset |
If set, mask values outside the mask rectangle will be inverted. By default, everything outside the mask rectangle has zero mask value. When this property is set, the mask outsides will have value one, which means that everything outside the mask will be visible. The mask rectangle is the RectTransform of the GameObject this component is attached to or separateMask if it's not null. The default value is false.
|
get |
Returns true if masking is currently active.
|
get |
Returns true if Soft Mask does raycast filtering, that is if the masked areas are transparent to input.
|
getset |
Specifies the minimum mask value that the point should have for an input event to pass. If the value sampled from the mask is greater or equal this value, the input event is considered 'hit'. The mask value is compared with raycastThreshold after channelWeights applied. The default value is 0, which means that any pixel belonging to RectTransform is considered in input events. If you specify the value greater than 0, the mask's texture should be readable. Accepts values in range [0..1].
|
getset |
Specifies a RectTransform that defines the bounds of the mask. Use of a separate RectTransform allows to move or resize mask bounds not affecting children. When null, the RectTransform of the current object is used. Default value is null.
|
getset |
Determines from where the mask image should be taken.
|
getset |
Specifies a Sprite that should be used as the mask image. This property takes effect only when the source is MaskSource.Sprite.
|
getset |
Specifies the draw mode of sprite borders. This property takes effect only when the source is MaskSource.Sprite.
|
getset |
Specifies a Texture2D that should be used as the mask image. This property takes effect only when the source is MaskSource.Texture.
|
getset |
Specifies a normalized UV-space rectangle defining the image part that should be used as the mask image. This property takes effect only when the source is MaskSource.Texture. A value is set in normalized coordinates. The default value is (0, 0, 1, 1), which means that the whole texture is used.