C# Класс Epigene.UI.UIManager

User interface manager. This class will manage the UI.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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

Описание методов

ActivateScreen() публичный Метод

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.
Результат Epigene.UI.UIScreen

Add() публичный Метод

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
Результат UIObject

AddDialog() публичный Метод

Add a dialog to available list
public AddDialog ( Epigene.UI.UIDialog dialog ) : void
dialog Epigene.UI.UIDialog
Результат void

AddScreen() публичный Метод

Add a new screen.
public AddScreen ( Epigene.UI.UIScreen screen ) : void
screen Epigene.UI.UIScreen
Результат void

BlinkImage() публичный Метод

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
Результат void

BlinkToggle() публичный Метод

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
Результат void

ChangeLayers() публичный статический Метод

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
Результат void

CheckTooltipVisibility() публичный Метод

Check if the tooltip can be visible at the moment or should be hidden
public CheckTooltipVisibility ( GameObject obj ) : bool
obj UnityEngine.GameObject
Результат bool

Clear() публичный Метод

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
Результат void

ClearHuds() публичный Метод

Remove all registered screens.
public ClearHuds ( ) : void
Результат void

ClearModels() публичный Метод

public ClearModels ( ) : void
Результат void

ClearPopups() публичный Метод

public ClearPopups ( ) : void
Результат void

ClearScreens() публичный Метод

Remove all registered screens.
public ClearScreens ( ) : void
Результат void

ClearUI() публичный Метод

Remove all registered UIImages, where type is match
public ClearUI ( UIType type ) : void
type UIType
Результат void

ContainsButton() публичный Метод

Check if the button already exist.
public ContainsButton ( int id ) : bool
id int
Результат bool

ContainsHud() публичный Метод

Check if the Hud already exist.
public ContainsHud ( string id ) : bool
id string
Результат bool

ContainsModel() публичный Метод

Check if the Model already exist.
public ContainsModel ( string id ) : bool
id string
Результат bool

ContainsPopup() публичный Метод

Check if the Popup already exist.
public ContainsPopup ( string id ) : bool
id string
Результат bool

ContainsScreen() публичный Метод

Check if the button already exist.
public ContainsScreen ( string name ) : bool
name string
Результат bool

CreateGameObject() публичный статический Метод

Helper to create a gameobject from a prefab.
public static CreateGameObject ( string prefab ) : GameObject
prefab string
Результат UnityEngine.GameObject

CreateImage() публичный Метод

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
Результат UIImage

CreateTexture() публичный статический Метод

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
Результат UnityEngine.Texture2D

DisableButton() публичный статический Метод

public static DisableButton ( Epigene.UI.UIButton b ) : void
b Epigene.UI.UIButton
Результат void

DisableHuds() публичный Метод

Disable all the huds
public DisableHuds ( ) : void
Результат void

EnableButton() публичный статический Метод

public static EnableButton ( Epigene.UI.UIButton b ) : void
b Epigene.UI.UIButton
Результат void

Get() публичный Метод

public Get ( int id ) : UIObject
id int
Результат UIObject

Get() публичный Метод

public Get ( string name ) : UIObject
name string
Результат UIObject

GetDialog() публичный Метод

Get a dialog from available list by id
public GetDialog ( string id ) : Epigene.UI.UIDialog
id string
Результат Epigene.UI.UIDialog

GetHud() публичный Метод

Helper to get the game object for a hud. TODOstatic??
public GetHud ( string id, string prefab = null ) : GameObject
id string
prefab string
Результат UnityEngine.GameObject

GetHudNames() публичный Метод

Get name of used huds.
public GetHudNames ( object>.Dictionary dict ) : List
dict object>.Dictionary
Результат List

GetModel() публичный Метод

Helper to get the game object for a hud. TODOstatic??
public GetModel ( string id, string prefab = null ) : GameObject
id string
prefab string
Результат UnityEngine.GameObject

GetPopup() публичный Метод

Helper to get the game object for a popup. TODOstatic??
public GetPopup ( string id, string prefab = null ) : GameObject
id string
prefab string
Результат UnityEngine.GameObject

GetPopupNames() публичный Метод

Get name of used popups.
public GetPopupNames ( object>.Dictionary dict ) : List
dict object>.Dictionary
Результат List

GetScreen() публичный Метод

public GetScreen ( string name ) : Epigene.UI.UIScreen
name string
Результат Epigene.UI.UIScreen

GetScreenId() публичный Метод

Return the active screen Id
public GetScreenId ( ) : string
Результат string

GetVirtualCamera() публичный статический Метод

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
Результат UnityEngine.Camera

InitUI() публичный Метод

Helper to reset/recreate the ui parent objects
public InitUI ( GameObject parent ) : void
parent UnityEngine.GameObject
Результат void

IsLayerVisible() публичный статический Метод

Return if a layer is visible or not
public static IsLayerVisible ( string layerName ) : bool
layerName string
Результат bool

LoadPrefab() публичный Метод

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
Результат UnityEngine.GameObject

LoadResources() публичный Метод

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
Результат UIObject>.Dictionary

LoadResources() публичный Метод

Create a screen from a json file including all ui elements
public LoadResources ( string fileName, GameObject gameObject = null ) : void
fileName string
gameObject UnityEngine.GameObject
Результат void

LoadSprite() публичный статический Метод

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.
Результат UnityEngine.Sprite[]

Remove() публичный Метод

Remove an image type
public Remove ( int id ) : void
id int
Результат void

RemoveAllDialog() публичный Метод

Remove ALL dialogs
public RemoveAllDialog ( ) : void
Результат void

RemoveDialog() публичный Метод

Remove a dialog by id
public RemoveDialog ( string id ) : void
id string
Результат void

RemoveModal() публичный Метод

public RemoveModal ( ) : void
Результат void

SaveTextureToFile() публичный статический Метод

Save a texture into a file as png
public static SaveTextureToFile ( Texture2D texture, string fileName ) : void
texture UnityEngine.Texture2D
fileName string
Результат void

Screenshot() публичный статический Метод

Save the rectangle from the camera view as a texture.
public static Screenshot ( Camera camera, Rect rect ) : Texture2D
camera UnityEngine.Camera
rect UnityEngine.Rect
Результат UnityEngine.Texture2D

SetResolution() публичный Метод

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
Результат void

ShowLayer() публичный статический Метод

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
Результат void

ShowModal() публичный Метод

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
Результат void

SlideScreen() публичный Метод

public SlideScreen ( string screenName ) : Epigene.UI.UIScreen
screenName string
Результат Epigene.UI.UIScreen

ToggleLayer() публичный статический Метод

Togle a layer by name
public static ToggleLayer ( string layerName ) : void
layerName string
Результат void

UIManager() публичный Метод

Initializes a new instance of the UIManager class.
public UIManager ( ) : UnityEngine
Результат UnityEngine

Update() публичный Метод

Process inputs and update state of ui element.
public Update ( ) : void
Результат void