Skip to content

Getting Started

Matt Dean edited this page Nov 12, 2018 · 8 revisions

Welcome to kDecals!

The page will explain how to get started with kDecals for your project. First, clone or download a zip of this repository. Then you can either copy the kDecals and Gizmos folders into your project directory, or simply import kDecals.unitypackage directly into your project.

Placing Decals in Editor

Image here

Placing Decals in Editor.

To Place Decals in the Editor either use the Create menu in the Hierarchy and select kTools/Decal or use the Add Component menu to add the Decal component via kTools/Decal.

Decals can be positioned and scaled using the objects transform like any other GameObject. However, after positioning, you may need to update the Decal's projection. To do this use the three tool buttons on the Decal component's inspector. See The Decal component below.

Placing Decals at runtime

Image here

Placing Decals at runtime.

To place Decals at runtime use the API entry points in DecalSystem. This API allows you to create Decals manually, defining your own projection and pooling or simply use the supplied automatic methods. For more information see Scripting API.

The Decal component

Image here

Decal component.

The Decal component defines a Decal instance. It handles the Decal's transform and updates its renderer. It also contains useful placement tools described below.

Properties

Definition - Defines the ScriptableDecal to use for this Decal. This defines how the Decal will be rendered. For more information see the ScriptableDecal section below.

Tools

Move to nearest face - This button will move the Decal to snap to the nearest surface. It will not affect the Decals rotation, scale or projection (although some DecalDefinitions will render differently based on distance to surface).

Orientate to nearest face - This button will rotate the Decal to face the nearest surface and then update its projection to match. It will not move or scale the Decal.

Snap to nearest face - This button will move and rotate the Decal to snap to, and face the nearest surface and then update its projection to match. It will not scale the Decal.

ScriptableDecal

Image here

And example ScriptableDecal.

The ScriptableDecal defines a decal that you can then make instances of in the scene. It defines a shader and set of properties used when rendering Decals using this ScriptableDecal. It also provides pooling properties.

Common

Definition - Selects the DecalDefinition to use for this ScriptableDecal. This defines the shader and properties for this ScriptableDecal. You can choose between a range of supplied DecalDefinitions or create your own. For more information see Writing custom DecalDefinitions.

Pooling

Max Instances - When using decal pooling, this value will be the maximum amount of Decals that can be created using this ScriptableDecal. When this limit is reached, the DecalPooler will disable the oldest Decal using this ScriptableDecal when a new one is requested, maintaining this limit.

Properties

Properties are defined by the selected DecalDefinition. They can contain any number of textures, colors, floats and vectors. Values assigned to these properties are send to the Decal's shader to be used in rendering.

Decal pooling

Image here

And example of Decal pooling.

Decal pooling is handled automatically when Decals are created at runtime with the usePooling parameter set to true. A DecalPooler will be created in the scene (if there is none already) and a DecalPool will be created of the ScriptableDecal type requested through the API. The number of Decal instances created within the pool will be equal to the Max Instances parameter on the ScriptableDecal. They will be disabled until an instance is requested by the API.

Clone this wiki locally