Display


Game Framework provides a number of components and libraries for helping you manage display related aspects of your game including positioning, movement, particles and more.

Display

GameManager provides a couple of useful properties that can be used for information about the current display. WorldSize, WorldBottomLeft and WorldTopRight give quick access to the current dimensions and location of the main camera’s view.

While less common, in certain cases you will need to handle differences in physical device sizes. The AspectRatioMultiplier property can be used to give a factor of how the current aspect ratio differs from a baseline 4:3 ratio, while PhysicalScreenHeightMultiplier returns a factor of how the current physical height differs from a predefined value that you set in the inspector ReferencePhysicalScreenHeightInInches field. With this you can work against a test device that you may have and know it will work for other formats..

To handle changes to any of the above GameManager will send out the messages DeviceOrientationChangedMessage for orientation changes and ResolutionChangedMessage for any resolution changes.

The DisplayMetrics class is also provided which has helper methods for working with different display types.

Positioning and Movement

There are a number of components that you can add to your gameobjects to quickly provide for simple movement and positioning that are listed below. In addition the PositionHelper class provides helper methods for various positioning and movement related needs. The extras bundle contains a sample under FlipWebApps\GameFrameworkTutorials\Display\Placement\ that demonstrates usage of the below.

Aligning with others

AlignScreenBounds will let you automatically align a gameobject with a specified screen border which can be useful when dealing with different sized displays to have items automatically positioned. This currently only works with an orthographic main camera, so is most suited for 2D games.

CenterInCamera lets you keep a gameobject centered in the main camera optionally offset by a specified amount.

MoveWithTransform will make the gameobject to which it is added follow a specified target gameobject, keeping its original offset and applying an optional smoothing factor.

LookAtTransform will not change the position of the gameobject to which it is attached, however will keep it facing towards a specified target.

Constant Movement

FixedMovement and FixedRotation provide a very simple way to constantly move and rotate a gameobject. These can optionally work with the GameStructure components LevelManager and GameManager so that these movements only occur when a game is actually in progress, stopping when a game is won or lost.

FixedMovement

Destroying Gameobjects

ObjectDestroyer can be used to automatically destroy gameobjects with a given Tag. One ideal use case of this component is to destroy off screen gameobjects that are no longer needed such as projectiles. You can do this by creating adding it to an offscreen gameobject that covers enough space so that all items needing automatic destruction touch it.

Beautiful Transitions

The Beautiful Transitions asset provides many components and a full scripting API to move, rotate, animate and transition gameobjects, UI elements and much more. It is included in the extras bundle or available separately.

Particles

Game Framework contains a couple of gameobjects to help our with using particle systems.

AutoDestructWhenParticleSystemFinished will destroy or disable a gameobject when a particle system on the same gameobject completed. This can be useful if you want some way of taking action on a gameobject once a particle system has completed such as when you destroy an enemy.

ParticlePlayer provides a simple callback method that can be triggered from other components and creates and plays a particle system. This can be used to trigger a repeating event based particle system.

Color

The ColorHelper and ColorHSV classes provide some useful functions for working with, converting and manipulating color values both in RGB and HSV formats, including HSV extensions for the standard Unity Color class.

GradientBackground is useful for adding a dynamic smooth gradient as the background for your scenes. You can configure it with the colors and positioning of your choice. GradientBackgroundSplitMiddle is similar to GradientBackground but adds a third color that can be positioned between the two outer colors. Click the below images to see the used configuration.

Materials

A commonly used effect in games is something like moving water or fire. This is often achieved by scrolling a materials texture. Game Framework provides the ScrollMaterialComponent that lets you automatically apply this effect to your own gameobjects.

UV values control how a material is applied to a 3D model. The SetCubeUvs and SetQuadUvs components let you set a cube or quads UV values at runtime so you can dynamically apply and control how materials are applied.

Level Of Detail

Level Of Detail (LOD) is a simple technique that enables different gameobjects based upon their distance from the camera or some other targer. You can use the LevelOfDetail component to improve the performance of your games by replacing distant objects with lower detail models or even 2D representations.

LevelOfDetail

Other

The SetSortingLayer component can be used for automatically setting a Renderers sorting layer name and order.

There is a CoRoutines class with some transition effects that at this time is retained for compatibility. This is likely to be removed in a future version. You should consider using the scripting functionality of Beautiful Transitions if you need such functionality.

See also

If you have any thoughts or suggestions on improvements or additions to the display features then please let us know!