BowieCode
BowieCode copied to clipboard
Personal Code/Snippet Library for Unity 3D
trafficstars
BowieCode
Personal Code, Snippet & Reference Library for Unity 3D

Features
Components
BindToCamerawill bind it's transform to parent's camera's near or far. Handy for keeping thing to the front or the back of a camera.CameraFrustumGizmoalways shows the camera's frustum in the scene view. Even when the camera is not selected.CameraFaderfades the camera to a texture. It includes a inspector button to generate a solid color texture.DefaultInstanceGets/sets a single staticDefaultinstance. Rather than have singletons, instances can utilize this generic container. For exampleDefaultInstance<MyClass>.Set( this )andMyClass instance = DefaultInstance<MyClass>.Get().DestroyAllChildrendestroys the gameobject's children. Useful for dynamic content. Can be undone when in editor mode.DistributeChildrendistributes it's children between two points. The two points can be manipulated in the scene view.DropdownCameraSelectorbinds a list of cameras to a UI.Dropdown.GridRepeaterclones prefabs into a grid.InstantiateAtTagcreates instances of a prefab in the scene at the position of game objects with a certain tag. When used in editor it can be undone. Instances can be parented with the game object at the tag, a container or the root of the scene.Motionapplies trig based motions to selectable variables of the transform component.MotionClonerapplies a master transforms position, rotation and scale to components transform. Provides options for using local or world space, and retaining offsets.MouseHiderhides the mouse after a set number of seconds.PivotGizmo3Ddraws customisable axises like the move tool when the object is not selected.SceneRecorderframe capture and video creation on OSX using ffmpeg installed by Homebrew.Singletoninherit from to make a singleton. SeeDefaultInstancefor a better system.Spawnerinstantiates prefabs in a random location within a predefined shape. It can set to do this every frame and spawn multiples.TextGizoalways displays text in the scene view
Managers
Managers use the BowieCode.DefaultInstance<T> system.
DebugNotificationManagerdisplays short notification labels with a severity level of either info, warning or error. They are displayed indefinitely or for a set timespan, and can be updated once displayed.AppManagerincludes:- hides the mouse if none are detected or after a set period of time,
- adds a checkbox to run application in the background.
Attributes
SortingLayerAttributeandSortingLayerDrawerprovides sorting layer selection for anint.TagAttributeandTagDrawerprovides range tag selection for astring. See: TagAttributeExample..LayerAttributeandLayerDrawerprovides layer selection for anint.MinMaxSliderAttributeandMinMaxSliderDrawerprovides range sliders forVector2. See: MinMaxSliderExample.InspectorButtonAttributeandInspectorButtonAttributecreates a button in the editor forInspectorButton. See: InspectorButtonExample.
Datatypes
-
Cyclewraps aEnumerableinto a container with aNextmethod. -
InspectorButtoncreates a button in the inspector when paired with anInspectorButtonAttribute. See: InspectorButtonExample. -
ParentingModehelps define where instanced GameObject should be placed. -
ShapedRangeevaluates to a constant value, a value between two numbers or a value from an Animation curve. These options can be selected in the editor. It's inspired by Unity's particle system.
Utils
BitmaskHelperprovidesIsSet,Set,Unsetfor enums which use the[Flags]attribute.BowieMathincludes:CompareVectorscompares if Vector are close to equal,MapIntervalFmaps an input float from one range to another,SinFis a sine wave generator with an amplitude, and frequency defined bycyclesPerSecond.
BowieTimefractional day & time and format helpers.BowieExtensionscontainsForEachWithIndexfor collection enumeration.- Editor Only:
ReorderableListUtilwrapper toCreateandDrawa reorderable list with the correct spacing. See example for usage. See: ReorderableListExample & ReorderableListExampleEditor.Prefabsenables a menu items to Apply selected prefabs.
