CW Spaceships


DOCUMENTATION

What is Spaceships?

Spaceships is a pack of high detail modular spaceship parts that can be combined together into an optimized object. You can then destroy the spaceships with an advanced visual destruction system.



Is URP/HDRP supported?

This asset supports all 3 render pipelines (Standard, URP, HDRP) in a seamless way that automatically detects your current project settings, and makes the required modifications to the scene so they look similar.


Better Shaders

This compatibility was made possible using the Better Shaders system (not required).

The Better Shaders asset generates multiple variants of each shader ahead of time, so even if you don't have this asset you will still be able to have full render pipeline compatibility with this asset.

BetterShaders (and therefore this asset) currently supports:

Standard - All versions supported by SGT.

URP7.x in Unity 2019.3LTS

URP10.x in Unity 2020.3LTS

URP12.x in Unity 2021.2

URP14.x in Unity 2022.2->2022.3LTS

HDRP7.x in Unity 2019.3LTS

HDRP10.x in Unity 2020.3LTS

HDRP12.x in Unity 2021.3LTS

HDRP14.x in Unity 2022.2->2022.3LTS

Support for newer versions will appear when it does in this asset.




How do I load a spaceship?


Step 1 - Spaceship Component

First you need to add the CwSpaceship component to your scene:

Method 1 From your menu bar, select GameObject > CW > Spaceships > Spaceship.
Method 2 Right click inside the Hierarchy tab, and go to CW > Spaceships > Spaceship.
Method 3 Create a new GameObject, and add the component CW > Spaceships > Spaceship.

Inside the Hierarchy tab you should now have a new GameObject selected with the CwSpaceship component attached to it.



Step 2 - Pick a Spaceship Design

Inside the CwSpaceship component is the Design setting.

This allows you to choose which spaceship design this spaceship will be based on.

This asset comes with several spaceship examples in the following folder: Plugins/CW/Spaceships/Designs

You can drag and drop one of the designs into the Design setting.



Step 3 - Done!

You can now enter play mode, and your spaceship design should load up.




How do I design a spaceship?


Step 1 - Create a Design

In the Project tab, right click a folder and select: Create > CW > Spaceships > Spaceship Design

You should now see a new prefab with the CwDesign component.

Alternatively, you could duplicate one of the existing spaceship designs, and modify it.

This asset comes with several spaceship examples in the following folder: Plugins/CW/Spaceships/Designs



Step 2 - Modify the Design

Double click your spaceship design prefab to edit it. The prefab root GameObject should have the CwDesign component, which allows you to choose the sticker pack and colors used in this spaceship design. This asset comes with a sticker pack so you can leave this as-is, but you can change the colors as you wish.



Step 3 - Add Some Parts

This asset comes with many spaceship part prefabs, which you can find in the following folder: Plugins/CW/Spaceships/Parts

While your spaceship design prefab is open, you can drag and drop these part prefabs onto the spaceship design to make them children.

Feel free to modify the Color Index setting, which allows you to change the base color of this part. This index is based on the color list you specify in the root CwDesign component.



Step 4 - Add Some Stickers

To make the spaceship designs look unique you can add stickers to them. These work like decals.

Feel free to modify the Color Index setting, which allows you to change the base color of this part. This index is based on the color list you specify in the root CwDesign component.

Feel free to modify the Texture Index setting, which allows you to change the texture of this sticker. This index is based on the texture list inside the sticker pack you specify in the root CwDesign component.

The other settings a little more complex, so I recommend you read the tooltip text and/or experiment with them to see how they work.



Step 5 - Compile!

Once you've placed your parts and stickers, it's time to compile it into optimized meshes.

STEP 1  Save your spaceship design prefab, and exit prefab editing mode (you can click the <button at the top left of the Hierarchy window.
STEP 2  Select your spaceship design prefab in the Project window.
STEP 3  See the spaceship design prefab's CwDesign component settings in the Inspector tab.
STEP 4  Click the Compile button.

Done! You can now load this spaceship design in your game.




How do I add scripts/effects/etc to a design?

When you compile the spaceship design, all spaceship parts will be combined into optimized meshes. When you load this design in-game, these optimized meshes will be loaded, but any additional GameObjects or scripts will be ignored and therefore not be loaded with your spaceship.

To make specific GameObjects persist between your design and loaded spaceship, you must add the CwModule component to them.

The example spaceships use this feature for the thruster effect GameObjects, allowing you to place them while designing the ship, and still have the thruster effect appear when the ship is loaded.

NOTE  You should only add this component to normal GameObjects. If you add this component to spaceship part prefabs (e.g. the ones that come with this asset to build the ship), then things may break.






Assets

Here's a list of all my other assets, please check them out!

You can also view this list on my Asset Store page.

Lean Touch

Lean Touch

Rapidly develop your game with consistent input across desktop & mobile using Lean Touch. This lightweight asset comes with many modular components, allowing you to customize them to your exact project needs!


Lean Touch+

Lean Touch+

Lean Touch+ is an extension to the popular Lean Touch asset, adding many more example scenes.


Lean Localization

Lean Localization

Lean Localization is a localization library that's designed to be as simple to use as possible for both designers, and programmers.


Lean Pool

Lean Pool

Quickly optimize the performance of your games using Lean Pool. Within minutes you can use this lightweight asset to preload, recycle, and limit the spawning of your prefabs.


Lean Transition

Lean Transition

Quickly polish your games using Lean Transition. This asset allows you to easily tween or animate almost anything in your game, making it transition smoothly.


Lean GUI

Lean GUI

Lean GUI is a colllection of components that extend Unity's GUI system, allowing you to rapidly enhance the user experience (UX) of your game's UI.


Lean GUI Shapes

Lean GUI Shapes

Lean GUI Shapes allows you to quickly add lines, rounded boxes, polygons, and much more to your GUI!


Lean Texture

Lean Texture

Lean Texture allows you quickly modify textures in your project with a range of filters, pack them together into channels, and much more!


Lean Texture+

Lean Texture+

Lean Texture+ is an extension to Lean Texture, adding many new types of texture modification tools!


CW Spaceships - Build & Destroy

Spaceships - Build & Destroy

Build your dream spaceship, and then have fun destroying it!


Modular Backgrounds

Modular Backgrounds

Unlock a universe of visual possibilities with Modular Backgrounds. Simply drag and drop these graphics into the background of your scenes.


Paint in 3D

Paint in 3D

Paint all your objects using Paint in 3D - both in game, and in editor. All features are optimized with GPU accelerated texture painting, so you can enjoy consistent performance, even if you paint your objects one million times!


Paint in 2D

Paint in 2D

Paint all your sprites with Paint in 2D. With incredible performance on mobile, WebGL, and much more!


Paint in Editor

Paint in Editor

Paint in Editor unlocks the ability to paint objects in your scene - great for making small tweaks, or even creating entirely new texture sets!


FLOW

FLOW

FLOW allows you to add large scale interactive fluids to your scene - all highly optimized using GPU acceleration.


Destructible 2D

Destructible 2D

Unlock the full potential of your 2D games using Destructible 2D, this asset allows you to quickly convert all your boring solid sprites into fully destructible ones!


Space Graphics Toolkit

Space Graphics Toolkit

Quickly make the space scene of your dreams using Space Graphics Toolkit. This huge collection of space effects can be customized and combined in any way you like, allowing you to quickly make realistic or fantasy worlds. Each feature has been heavily optimized to run on almost any device and platform.


Space Graphics Planets

Space Graphics Planets

Enhance your space scenes using this large pack of high detail volumetric planets. These planets are finished using the powerful planet features from Space Graphics Toolkit (not required).


Volumetric Audio

Volumetric Audio

Unity sounds only emanate from a single point source. This is great for explosions and footsteps, but quite often you need something more advanced. Volumetric Audio is an easy to use package that allows you to define boxes, spheres, capsules, paths, or meshes that sounds can emanate from.






Versions

1.1.1

Fixed atlas size error when compiling ship designs in some scenarios.
Allowed compiling ship designs with parts that don't have decals or visuals or colliders.



1.1.0

Updated CW/Common code to latest version.
Updated shaders to latest version.



1.0.5

Moved main build to Unity 2021.3.0f1.
Updated shaders to latest version.



1.0.4

Fixed shader error in URP 2022 LTS.



1.0.3

Updated shaders for URP and HDRP.
Added CwPart.TilingUV setting.
Fixed Body_Connector_02 part.
Fixed spaceship shader's normal maps.



1.0.2

Fixed CwExplosion component's Radius setting.
Fixed UV mapping of parts with multiple meshes.
Fixed explosion heat glow effect not appearing in HDRP.
Added more explosion mark textures.
Added BASE / Emission Scale setting to Spaceship shader.
Added DECAL / Emission Scale setting to Spaceship shader.
Improved spaceship thruster effect.
Improved alternative base materials.



1.0.1

Fixed CwTapToSpawn when using InputSystem package.
Fixed CwSpaceship.AllowMarks setting starting with damage in builds.



1.0.0

Initial release.







Components

CwDebris

This component allows damaged parts break off from the main mesh so they can be manipulated separately.


bool
Detach

Should the debris detach from the main object?



bool
Rotate

Should the debris rotate?



float
RotationSpeedMin

When this debris is spawned, it will be given a random rotational velocity with this minimum speed in degrees per second.



float
RotationSpeedMax

When this debris is spawned, it will be given a random rotational velocity with this maximum speed in degrees per second.



float
Life

The debris will stay alive for this many seconds.




CwDesign

This component is the base of your object design. All parts of this object should be child GameObjects using the CwPart component. They can then be compiled into an optimized object.

NOTE  This component is usually the root component in a prefab for a specific design.

CwStickerPack
StickerPack

The parts of this design can have stickers from this sticker pack.



List<Color>
Colors

The parts and stickers will be colored based on this color palette.



Mesh
ShapeVisual

The compiled design's visual shape mesh will be stored here.



Mesh
DecalVisual

The compiled design's visual decal mesh will be stored here.



int
SecondarySize

The compiled design's damage atlas texture size in pixels.



Material[]
Materials

The compiled design's material set.



Matrix4x4[]
StickerMatrices

The compiled design's sticker matrices.



Vector4[]
StickerCoords

The compiled design's sticker UVs.



Vector4[]
StickerDataA

The compiled design's sticker color, offset, and sharpness data.



Vector4[]
StickerDataB

The compiled design's sticker normal data.



void
Compile

This method will convert all child parts into a single visual mesh and data for colliders.




CwDesignData

This class helps the design parts compile.



CwLoadedPart

When a design is loaded from its compiled state, its data will be copied into this class.


float
Damage

The amount of damage this part has received.



Vector3
Center

The center/pivot of this part relative to the compiled mesh.



bool
Detached

The amount of damage this part has received.




CwLoader

This component is used in-game to load a from previously built design.

This component also handles visual damage, and allows you to override materials or colors from the design.


CwDesign
Design

This allows you to choose which design will be loaded by this component.



bool
AllowMarks

Do you want to allow damage mark and holes?

NOTE  Marks can be applied manually using the ApplyMark/All methods, or in the editor using the CwExplosion component.


List<MaterialOverride>
MaterialOverrides

This allows you to replace any of the materials used in the design during loading.



List<ColorOverride>
ColorOverrides

This allows you to replace any of the colors used in the design during loading.



List<CwLoadedPart>
LoadedParts

After a design is loaded, all of its parts are stored here.



RenderTexture
MarkTexture

The visual damage data will be stored in this texture.



MeshRenderer
ShapeRenderer

The MeshRenderer used to draw the shape mesh.



MeshRenderer
DecalRenderer

The MeshRenderer used to draw the decal mesh.



bool
AllowRemoval

If you enable this setting then damaged parts can be broken off.



CwDebris
DebrisPrefab

When a part is destroyed it can break off and become debris. This setting allows you to choose what the debris settings will be based on.

None/null = Immediately destroy.



void
ClearMarksTex

If this object has damage marks, then this method will heal them all.




CwModule

This component can be added to any GameObject in your design, and when your design is loaded this GameObject will appear as-is.


CwPart
DesignPart

This allows you to specify which part this module will be associated with.




CwPart

This component is applied to raw design parts and is usually the root component of each part.

NOTE  This component must be in a child GameObject of the CwDesign component.

string
ModelGuid

This design part is based on this raw model.



Material
Material

The Material used to render this part.



float
Health

The maximum health value of this part.



OffsetType
OffsetMode

If you have multiple copies of the same part then their base texture can look repetitive. This setting allows you to offset the UV so they look slightly different.

Manual = You can manually specify the UV offset.

PositionHash = The UV offset will automatically be generated based on the position.



Vector2
Offset

If you have multiple copies of the same part then their base texture can look repetitive. This setting allows you to offset the UV so they look slightly different.



float
Tiling

The base texture scale of this part.

NOTE  This is automatically calculated when updating the part from the model.


Vector2
TilingUV

This is multiplied by the Tiling value, and allows you to manually modify the U and V tiling values.



int
ColorIndex

The base color of this part based on the color list in the root design component.




CwSpaceship CwLoader

This class contains some useful methods used by this asset.


float
CooldownSpeed

The heat glow from explosion marks will fade out at this speed.

1 = Fades out in one second.

2 = Fades out in half a second.



byte
CooldownThreshold

The cooldown value must accumulate by this much (1..255) before it gets applied. The higher you set this the higher the performance, but the choppier the fade out will be.




CwSticker

This component allows you to apply a sticker to your design at the current Transform.

NOTE  This component must be in a child GameObject of the CwDesign component.

int
TextureIndex

This sticker will use this texture index from the sticker pack set in the parent CwDesign component.



int
ColorIndex

This sticker will use this color index from the colors list set in the parent CwDesign component.



float
NormalBack

This allows you to hide the pixels of the sticker that lie on surfaces that are too steep relative to the back of the sticker.



float
NormalFront

This allows you to hide the pixels of the sticker that lie on surfaces that are too steep relative to the front of the sticker.



float
Offset

This allows you to shrink or expand the outer edge of the decal shape, similar to the threshold setting of a cutout shader.



float
Sharpness

This allows you to control the edge transition sharpness/smoothness.




CwStickerPack

This component allows you to define a collection of textures that get packed into an atlas that can then be applied to spaceship designs.


List<Sticker>
Stickers

The stickers contained in this sticker pack.




CwTapToSpawn

This component spawns the specified finger under the screen using a physics raycast.


CwInputManager.Trigger
spawnControls

The finger/mouse/key that triggers the spawning.



GameObject
Prefab

The prefab this component will be spawned.



float
Damage

The amount of damage applied to spaceship parts.



float
Interval

The amount of seconds between each spawn if you hold down the mouse/finger.

-1 = Only spawn once per click/tap.




Index

What is Spaceships?

Is URP/HDRP supported?

How do I load a spaceship?

How do I design a spaceship?

How do I add scripts/effects/etc to a design?



Assets

Lean Touch

Lean Touch+

Lean Localization

Lean Pool

Lean Transition

Lean GUI

Lean GUI Shapes

Lean Texture

Lean Texture+

Spaceships - Build & Destroy

Modular Backgrounds

Paint in 3D

Paint in 2D

Paint in Editor

FLOW

Destructible 2D

Space Graphics Toolkit

Space Graphics Planets

Volumetric Audio



Versions

1.1.1

1.1.0

1.0.5

1.0.4

1.0.3

1.0.2

1.0.1

1.0.0



Components

CwDebris

CwDesign

CwDesignData

CwLoadedPart

CwLoader

CwModule

CwPart

CwSpaceship

CwSticker

CwStickerPack

CwTapToSpawn