C# Class Epigene.UI.UIManager

User interface manager. This class will manage the UI.
Mostrar archivo Open project: fi-content2-games-platform/FIcontent.Gaming.Enabler.phenomobilecharactermanager Class Usage Examples

Public Methods

Method Description
ActivateScreen ( string screenName ) : Epigene.UI.UIScreen

Activate a screen by name. This function will deactivat old screen and activate the new one. It will also send a notification to screenChanged(old, new) if any delegates is set.

Add ( UIType type, GameObject obj, string fileName, Sprite spr = null ) : UIObject

Adds a UI button.

AddDialog ( Epigene.UI.UIDialog dialog ) : void

Add a dialog to available list

AddScreen ( Epigene.UI.UIScreen screen ) : void

Add a new screen.

BlinkImage ( UIImage image, int numberOfblinks = 2, double speedInMs = 200 ) : void

Blink an image by numberOfBlinks times. The speed of blinks depends on the speedInMs parameter.

BlinkToggle ( UIImage image ) : void

Helper for processing blinking of an image. It will toggle the visible flag based on the preset values

ChangeLayers ( GameObject obj, string name ) : void

Change layers in game objet and in all of it's children

CheckTooltipVisibility ( GameObject obj ) : bool

Check if the tooltip can be visible at the moment or should be hidden

Clear ( bool force = false ) : void

Free up memory with dropping all ui objects. Clears UI elements with removing them from internal lists and destroys them.

ClearHuds ( ) : void

Remove all registered screens.

ClearModels ( ) : void
ClearPopups ( ) : void
ClearScreens ( ) : void

Remove all registered screens.

ClearUI ( UIType type ) : void

Remove all registered UIImages, where type is match

ContainsButton ( int id ) : bool

Check if the button already exist.

ContainsHud ( string id ) : bool

Check if the Hud already exist.

ContainsModel ( string id ) : bool

Check if the Model already exist.

ContainsPopup ( string id ) : bool

Check if the Popup already exist.

ContainsScreen ( string name ) : bool

Check if the button already exist.

CreateGameObject ( string prefab ) : GameObject

Helper to create a gameobject from a prefab.

CreateImage ( string id, string filename, GameObject parent, GameObject obj = null ) : UIImage

Create a new push or toggle button

CreateTexture ( GameObject obj, Rect rect, float orthSize ) : Texture2D

Create a texture from game object. It will clone the object and the camera, create a screenshot of the camera and save it. Set rect to the size of the new image.

DisableButton ( Epigene.UI.UIButton b ) : void
DisableHuds ( ) : void

Disable all the huds

EnableButton ( Epigene.UI.UIButton b ) : void
Get ( int id ) : UIObject
Get ( string name ) : UIObject
GetDialog ( string id ) : Epigene.UI.UIDialog

Get a dialog from available list by id

GetHud ( string id, string prefab = null ) : GameObject

Helper to get the game object for a hud. TODOstatic??

GetHudNames ( object>.Dictionary dict ) : List

Get name of used huds.

GetModel ( string id, string prefab = null ) : GameObject

Helper to get the game object for a hud. TODOstatic??

GetPopup ( string id, string prefab = null ) : GameObject

Helper to get the game object for a popup. TODOstatic??

GetPopupNames ( object>.Dictionary dict ) : List

Get name of used popups.

GetScreen ( string name ) : Epigene.UI.UIScreen
GetScreenId ( ) : string

Return the active screen Id

GetVirtualCamera ( float orthSize ) : Camera

Get a virtual camera, which can render the object alone. The new camera cloned from the current main camera or from a it's prefab in case of no main camera.

InitUI ( GameObject parent ) : void

Helper to reset/recreate the ui parent objects

IsLayerVisible ( string layerName ) : bool

Return if a layer is visible or not

LoadPrefab ( string prefab, string name, GameObject parent ) : GameObject

Helper to load a prefab by name under specific parent

LoadResources ( object>.Dictionary dict, GameObject gameObject = null ) : UIObject>.Dictionary

Load object resources from dictionary TODO make more generic helpers and way of parse similar stuff. ie. transform parameter should be one parser for all

LoadResources ( string fileName, GameObject gameObject = null ) : void

Create a screen from a json file including all ui elements

LoadSprite ( string fileName ) : UnityEngine.Sprite[]

Loads a sprite and return a list of textures. If the sprite is in multi mode, the list will contains each sprites. If the sprite is single mode, the list will contains only one item.

Remove ( int id ) : void

Remove an image type

RemoveAllDialog ( ) : void

Remove ALL dialogs

RemoveDialog ( string id ) : void

Remove a dialog by id

RemoveModal ( ) : void
SaveTextureToFile ( Texture2D texture, string fileName ) : void

Save a texture into a file as png

Screenshot ( Camera camera, Rect rect ) : Texture2D

Save the rectangle from the camera view as a texture.

SetResolution ( int w, int h, bool fullScreen ) : void

Helper to notify when screen is resizes.

ShowLayer ( string layerName, bool flag ) : void

Show and hide a layer by name If flag is set to true, it will show the layer if flag is false, it will hide the layer

ShowModal ( GameObject obj ) : void

Use this function to show (activate) an object in modal mode. While the object is active, it will capture all user inputs and gets all focus. Deactivating the object will trigger the uimanager to go back to normal mode (hide and forget).

SlideScreen ( string screenName ) : Epigene.UI.UIScreen
ToggleLayer ( string layerName ) : void

Togle a layer by name

UIManager ( ) : UnityEngine

Initializes a new instance of the UIManager class.

Update ( ) : void

Process inputs and update state of ui element.

Private Methods

Method Description
GetObjectUnderCursor ( ) : GameObject

Get an object under the cursor

GetUIButtonFromObject ( GameObject obj ) : Epigene.UI.UIButton

Internal helper to get a uiButton from an object

InternalInit ( ) : void

Method Details

ActivateScreen() public method

Activate a screen by name. This function will deactivat old screen and activate the new one. It will also send a notification to screenChanged(old, new) if any delegates is set.
public ActivateScreen ( string screenName ) : Epigene.UI.UIScreen
screenName string The name of the screen.
return Epigene.UI.UIScreen

Add() public method

Adds a UI button.
public Add ( UIType type, GameObject obj, string fileName, Sprite spr = null ) : UIObject
type UIType
obj UnityEngine.GameObject Parent game object.
fileName string Resource file name with path, relative to Rersources folder.
spr UnityEngine.Sprite
return UIObject

AddDialog() public method

Add a dialog to available list
public AddDialog ( Epigene.UI.UIDialog dialog ) : void
dialog Epigene.UI.UIDialog
return void

AddScreen() public method

Add a new screen.
public AddScreen ( Epigene.UI.UIScreen screen ) : void
screen Epigene.UI.UIScreen
return void

BlinkImage() public method

Blink an image by numberOfBlinks times. The speed of blinks depends on the speedInMs parameter.
public BlinkImage ( UIImage image, int numberOfblinks = 2, double speedInMs = 200 ) : void
image UIImage
numberOfblinks int
speedInMs double
return void

BlinkToggle() public method

Helper for processing blinking of an image. It will toggle the visible flag based on the preset values
public BlinkToggle ( UIImage image ) : void
image UIImage
return void

ChangeLayers() public static method

Change layers in game objet and in all of it's children
public static ChangeLayers ( GameObject obj, string name ) : void
obj UnityEngine.GameObject
name string
return void

CheckTooltipVisibility() public method

Check if the tooltip can be visible at the moment or should be hidden
public CheckTooltipVisibility ( GameObject obj ) : bool
obj UnityEngine.GameObject
return bool

Clear() public method

Free up memory with dropping all ui objects. Clears UI elements with removing them from internal lists and destroys them.
public Clear ( bool force = false ) : void
force bool
return void

ClearHuds() public method

Remove all registered screens.
public ClearHuds ( ) : void
return void

ClearModels() public method

public ClearModels ( ) : void
return void

ClearPopups() public method

public ClearPopups ( ) : void
return void

ClearScreens() public method

Remove all registered screens.
public ClearScreens ( ) : void
return void

ClearUI() public method

Remove all registered UIImages, where type is match
public ClearUI ( UIType type ) : void
type UIType
return void

ContainsButton() public method

Check if the button already exist.
public ContainsButton ( int id ) : bool
id int
return bool

ContainsHud() public method

Check if the Hud already exist.
public ContainsHud ( string id ) : bool
id string
return bool

ContainsModel() public method

Check if the Model already exist.
public ContainsModel ( string id ) : bool
id string
return bool

ContainsPopup() public method

Check if the Popup already exist.
public ContainsPopup ( string id ) : bool
id string
return bool

ContainsScreen() public method

Check if the button already exist.
public ContainsScreen ( string name ) : bool
name string
return bool

CreateGameObject() public static method

Helper to create a gameobject from a prefab.
public static CreateGameObject ( string prefab ) : GameObject
prefab string
return UnityEngine.GameObject

CreateImage() public method

Create a new push or toggle button
public CreateImage ( string id, string filename, GameObject parent, GameObject obj = null ) : UIImage
id string
filename string
parent UnityEngine.GameObject
obj UnityEngine.GameObject
return UIImage

CreateTexture() public static method

Create a texture from game object. It will clone the object and the camera, create a screenshot of the camera and save it. Set rect to the size of the new image.
public static CreateTexture ( GameObject obj, Rect rect, float orthSize ) : Texture2D
obj UnityEngine.GameObject
rect UnityEngine.Rect
orthSize float
return UnityEngine.Texture2D

DisableButton() public static method

public static DisableButton ( Epigene.UI.UIButton b ) : void
b Epigene.UI.UIButton
return void

DisableHuds() public method

Disable all the huds
public DisableHuds ( ) : void
return void

EnableButton() public static method

public static EnableButton ( Epigene.UI.UIButton b ) : void
b Epigene.UI.UIButton
return void

Get() public method

public Get ( int id ) : UIObject
id int
return UIObject

Get() public method

public Get ( string name ) : UIObject
name string
return UIObject

GetDialog() public method

Get a dialog from available list by id
public GetDialog ( string id ) : Epigene.UI.UIDialog
id string
return Epigene.UI.UIDialog

GetHud() public method

Helper to get the game object for a hud. TODOstatic??
public GetHud ( string id, string prefab = null ) : GameObject
id string
prefab string
return UnityEngine.GameObject

GetHudNames() public method

Get name of used huds.
public GetHudNames ( object>.Dictionary dict ) : List
dict object>.Dictionary
return List

GetModel() public method

Helper to get the game object for a hud. TODOstatic??
public GetModel ( string id, string prefab = null ) : GameObject
id string
prefab string
return UnityEngine.GameObject

GetPopup() public method

Helper to get the game object for a popup. TODOstatic??
public GetPopup ( string id, string prefab = null ) : GameObject
id string
prefab string
return UnityEngine.GameObject

GetPopupNames() public method

Get name of used popups.
public GetPopupNames ( object>.Dictionary dict ) : List
dict object>.Dictionary
return List

GetScreen() public method

public GetScreen ( string name ) : Epigene.UI.UIScreen
name string
return Epigene.UI.UIScreen

GetScreenId() public method

Return the active screen Id
public GetScreenId ( ) : string
return string

GetVirtualCamera() public static method

Get a virtual camera, which can render the object alone. The new camera cloned from the current main camera or from a it's prefab in case of no main camera.
public static GetVirtualCamera ( float orthSize ) : Camera
orthSize float
return UnityEngine.Camera

InitUI() public method

Helper to reset/recreate the ui parent objects
public InitUI ( GameObject parent ) : void
parent UnityEngine.GameObject
return void

IsLayerVisible() public static method

Return if a layer is visible or not
public static IsLayerVisible ( string layerName ) : bool
layerName string
return bool

LoadPrefab() public method

Helper to load a prefab by name under specific parent
public LoadPrefab ( string prefab, string name, GameObject parent ) : GameObject
prefab string
name string
parent UnityEngine.GameObject
return UnityEngine.GameObject

LoadResources() public method

Load object resources from dictionary TODO make more generic helpers and way of parse similar stuff. ie. transform parameter should be one parser for all
public LoadResources ( object>.Dictionary dict, GameObject gameObject = null ) : UIObject>.Dictionary
dict object>.Dictionary
gameObject UnityEngine.GameObject
return UIObject>.Dictionary

LoadResources() public method

Create a screen from a json file including all ui elements
public LoadResources ( string fileName, GameObject gameObject = null ) : void
fileName string
gameObject UnityEngine.GameObject
return void

LoadSprite() public static method

Loads a sprite and return a list of textures. If the sprite is in multi mode, the list will contains each sprites. If the sprite is single mode, the list will contains only one item.
public static LoadSprite ( string fileName ) : UnityEngine.Sprite[]
fileName string file name with path relative to Resource folder.
return UnityEngine.Sprite[]

Remove() public method

Remove an image type
public Remove ( int id ) : void
id int
return void

RemoveAllDialog() public method

Remove ALL dialogs
public RemoveAllDialog ( ) : void
return void

RemoveDialog() public method

Remove a dialog by id
public RemoveDialog ( string id ) : void
id string
return void

RemoveModal() public method

public RemoveModal ( ) : void
return void

SaveTextureToFile() public static method

Save a texture into a file as png
public static SaveTextureToFile ( Texture2D texture, string fileName ) : void
texture UnityEngine.Texture2D
fileName string
return void

Screenshot() public static method

Save the rectangle from the camera view as a texture.
public static Screenshot ( Camera camera, Rect rect ) : Texture2D
camera UnityEngine.Camera
rect UnityEngine.Rect
return UnityEngine.Texture2D

SetResolution() public method

Helper to notify when screen is resizes.
public SetResolution ( int w, int h, bool fullScreen ) : void
w int The new width.
h int The new height.
fullScreen bool
return void

ShowLayer() public static method

Show and hide a layer by name If flag is set to true, it will show the layer if flag is false, it will hide the layer
public static ShowLayer ( string layerName, bool flag ) : void
layerName string
flag bool
return void

ShowModal() public method

Use this function to show (activate) an object in modal mode. While the object is active, it will capture all user inputs and gets all focus. Deactivating the object will trigger the uimanager to go back to normal mode (hide and forget).
public ShowModal ( GameObject obj ) : void
obj UnityEngine.GameObject
return void

SlideScreen() public method

public SlideScreen ( string screenName ) : Epigene.UI.UIScreen
screenName string
return Epigene.UI.UIScreen

ToggleLayer() public static method

Togle a layer by name
public static ToggleLayer ( string layerName ) : void
layerName string
return void

UIManager() public method

Initializes a new instance of the UIManager class.
public UIManager ( ) : UnityEngine
return UnityEngine

Update() public method

Process inputs and update state of ui element.
public Update ( ) : void
return void