Adventure Creator  1.66.1
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2018
AC.UnityVersionHandler Class Reference

Static Public Member Functions

static RaycastHit2D Perform2DRaycast (Vector2 origin, Vector2 direction, float length, LayerMask layerMask)
 Performs a Physics2D.Raycast on Triggers in the scene. More...
 
static RaycastHit2D Perform2DRaycast (Vector2 origin, Vector2 direction, float length)
 Performs a Physics2D.Raycast on Triggers in the scene. More...
 
static int Perform2DOverlapCircle (Vector2 point, float radius, Collider2D[] results, LayerMask layerMask)
 Performs a Physics2D.OverlapCircle on Triggers in the scene. More...
 
static int Perform2DOverlapPoint (Vector2 point, Collider2D[] results, LayerMask layerMask)
 Performs a Physics2D.OverlapPoint on Triggers in the scene. More...
 
static Vector3 Get2DHotspotOffset (BoxCollider2D _boxCollider2D, Transform transform)
 Gets the offset/centre of a 2D Hotspot's icon in relation to the Hotspot's centre. More...
 
static void SetCursorVisibility (bool state)
 Sets the visiblity of the cursor. More...
 
static int GetCurrentSceneNumber ()
 Gets the index number of the active scene, as listed in the Build Settings. More...
 
static SceneInfo GetSceneInfoFromGameObject (GameObject _gameObject)
 Gets a SceneInfo class for the scene that a given GameObject is in. More...
 
static LocalVariables GetLocalVariablesOfGameObject (GameObject _gameObject)
 Gets the LocalVariables component that is in the same scene as a given GameObject. More...
 
static SceneSettings GetSceneSettingsOfGameObject (GameObject _gameObject)
 Gets the SceneSettings component that is in the same scene as a given GameObject. More...
 
static string GetCurrentSceneName ()
 Gets the name of the active scene. More...
 
static void OpenScene (string sceneName, bool forceReload=false, bool loadAdditively=false)
 Loads a scene by name. More...
 
static void OpenScene (int sceneNumber, bool forceReload=false, bool loadAdditively=false)
 Loads a scene by index number, as listed in the Build Settings. More...
 
static bool CloseScene (string sceneName)
 Closes a scene by name. More...
 
static bool CloseScene (int sceneNumber)
 Closes a scene by index number, as listed in the Build Settings. More...
 
static AsyncOperation LoadLevelAsync (int sceneNumber, string sceneName="")
 Loads the scene asynchronously. More...
 
static bool CanUseJson ()
 Checks if Json serialization is supported by the current version of Unity. More...
 
static bool PutInFolder (GameObject ob, string folderName)
 Places a supplied GameObject in a "folder" scene object, as generated by the Scene Manager. More...
 
static void NewScene ()
 
static void SaveScene ()
 
static bool SaveSceneIfUserWants ()
 
static void SetWindowTitle< T > (T window, string label)
 Sets the title of an editor window (Unity Editor only). More...
 
static Vector2 GetBoxCollider2DCentre (BoxCollider2D _boxCollider2D)
 
static void SetBoxCollider2DCentre (BoxCollider2D _boxCollider2D, Vector2 offset)
 
static string GetActiveSceneName ()
 Gets the name of the active scene, if multiple scenes are being edited. More...
 
static bool ObjectIsInActiveScene (string gameObjectName)
 Checks if a suppplied GameObject is present within the active scene. More...
 
static T AddComponentToGameObject< T > (GameObject gameObject)
 Adds a component to a GameObject, which can be a prefab or a scene-based object More...
 
static T AddConstantIDToGameObject< T > (GameObject gameObject, bool forcePrefab=false)
 Adds a ConstantID component to a GameObject, which can be a prefab or a scene-based object More...
 
static void AssignIDsToTranslatable (ITranslatable translatable, int[] lineIDs, bool isInScene, bool isMonoBehaviour)
 
static bool IsPrefabFile (Object _target)
 Checks if a given object is part of an original prefab (as opposed to an instance of one). More...
 
static bool IsPrefabEditing (Object _target)
 
static void CustomSetDirty (Object _target, bool force=false)
 
static string GetCurrentSceneFilepath ()
 
static bool ShouldAssignPrefabConstantID (GameObject gameObject)
 
static bool ObjectIsInActiveScene (GameObject gameObject)
 Checks if a suppplied GameObject is present within the active scene. The GameObject must be in the Hierarchy at runtime. More...
 
static bool ObjectIsInScene (GameObject gameObject, int sceneIndex)
 Checks if a suppplied GameObject is present within a given scene. The GameObject must be in the Hierarchy at runtime. More...
 
static T GetKickStarterComponent< T > ()
 Finds the correct instance of a component required by the KickStarter script.
 
static T GetOwnSceneInstance< T > (GameObject gameObject)
 Gets a Behaviour that is in the same scene as a given GameObject. More...
 
static T [] GetOwnSceneComponents< T > (GameObject gameObject=null)
 Gets all instances of a Component that are in the same scene as a given GameObject. More...
 
static UnityEngine.EventSystems.EventSystem CreateEventSystem ()
 

Properties

static bool CursorLock [get, set]
 

Detailed Description

This is a class that contains commonly-used functions that vary depending on which version of Unity is being used.

Member Function Documentation

◆ AddComponentToGameObject< T >()

static T AC.UnityVersionHandler.AddComponentToGameObject< T > ( GameObject  gameObject)
static

Adds a component to a GameObject, which can be a prefab or a scene-based object

Parameters
gameObjectThe GameObject to amend
Returns
The GameObject's component
Type Constraints
T :Component 

◆ AddConstantIDToGameObject< T >()

static T AC.UnityVersionHandler.AddConstantIDToGameObject< T > ( GameObject  gameObject,
bool  forcePrefab = false 
)
static

Adds a ConstantID component to a GameObject, which can be a prefab or a scene-based object

Parameters
gameObjectThe GameObject to amend
Returns
The GameObject's component
Type Constraints
T :ConstantID 

◆ CanUseJson()

static bool AC.UnityVersionHandler.CanUseJson ( )
static

Checks if Json serialization is supported by the current version of Unity.

Returns
True if Json serialization is supported by the current version of Unity.

◆ CloseScene() [1/2]

static bool AC.UnityVersionHandler.CloseScene ( string  sceneName)
static

Closes a scene by name.

Parameters
sceneNameThe name of the scene to load
Returns
True if the close was successful

◆ CloseScene() [2/2]

static bool AC.UnityVersionHandler.CloseScene ( int  sceneNumber)
static

Closes a scene by index number, as listed in the Build Settings.

Parameters
sceneNumberThe index number of the scene to load, as listed in the Build Settings
Returns
True if the close was successful

◆ CreateEventSystem()

static UnityEngine.EventSystems.EventSystem AC.UnityVersionHandler.CreateEventSystem ( )
static

Creates a generic EventSystem object for Unity UI-based Menus to use.

◆ CustomSetDirty()

static void AC.UnityVersionHandler.CustomSetDirty ( Object  _target,
bool  force = false 
)
static

Marks an object as dirty so that changes made will be saved. In Unity 5.3 and above, the scene itself is marked as dirty to ensure it is properly changed.

Parameters
_targetThe object to mark as dirty
forceIf True, then the object will be marked as dirty regardless of whether or not GUI.changed is true. This should not be set if called every frame.

◆ Get2DHotspotOffset()

static Vector3 AC.UnityVersionHandler.Get2DHotspotOffset ( BoxCollider2D  _boxCollider2D,
Transform  transform 
)
static

Gets the offset/centre of a 2D Hotspot's icon in relation to the Hotspot's centre.

Parameters
_boxCollider2DThe Hotspot's BoxCollider2D component.
transformThe Hotspot's Transform component.
Returns
The offset/centre of a 2D Hotspot's icon in relation to the Hotspot's centre.

◆ GetActiveSceneName()

static string AC.UnityVersionHandler.GetActiveSceneName ( )
static

Gets the name of the active scene, if multiple scenes are being edited.

Returns
The name of the active scene, if multiple scenes are being edited. Returns nothing otherwise.

◆ GetCurrentSceneName()

static string AC.UnityVersionHandler.GetCurrentSceneName ( )
static

Gets the name of the active scene.

Returns
The name of the active scene. If this is called in the Editor, the full filepath is also returned.

◆ GetCurrentSceneNumber()

static int AC.UnityVersionHandler.GetCurrentSceneNumber ( )
static

Gets the index number of the active scene, as listed in the Build Settings.

Returns
The index number of the active scene, as listed in the Build Settings.

◆ GetLocalVariablesOfGameObject()

static LocalVariables AC.UnityVersionHandler.GetLocalVariablesOfGameObject ( GameObject  _gameObject)
static

Gets the LocalVariables component that is in the same scene as a given GameObject.

Parameters
_gameObjectThe GameObject in the scene
Returns
The LocalVariables component that is in the same scene as the given GameObject

◆ GetOwnSceneComponents< T >()

static T [] AC.UnityVersionHandler.GetOwnSceneComponents< T > ( GameObject  gameObject = null)
static

Gets all instances of a Component that are in the same scene as a given GameObject.

Parameters
_gameObjectThe GameObject in the scene
Returns
All instances of a Component that are in the same scene as the given GameObject
Type Constraints
T :Component 

◆ GetOwnSceneInstance< T >()

static T AC.UnityVersionHandler.GetOwnSceneInstance< T > ( GameObject  gameObject)
static

Gets a Behaviour that is in the same scene as a given GameObject.

Parameters
_gameObjectThe GameObject in the scene
Returns
The Behaviour that is in the same scene as the given GameObject
Type Constraints
T :Behaviour 

◆ GetSceneInfoFromGameObject()

static SceneInfo AC.UnityVersionHandler.GetSceneInfoFromGameObject ( GameObject  _gameObject)
static

Gets a SceneInfo class for the scene that a given GameObject is in.

Parameters
_gameObjectThe GameObject in the scene
Returns
A SceneInfo class for the scene that a given GameObject is in.

◆ GetSceneSettingsOfGameObject()

static SceneSettings AC.UnityVersionHandler.GetSceneSettingsOfGameObject ( GameObject  _gameObject)
static

Gets the SceneSettings component that is in the same scene as a given GameObject.

Parameters
_gameObjectThe GameObject in the scene
Returns
The SceneSettings component that is in the same scene as the given GameObject

◆ IsPrefabFile()

static bool AC.UnityVersionHandler.IsPrefabFile ( Object  _target)
static

Checks if a given object is part of an original prefab (as opposed to an instance of one).

Parameters
_targetThe object being checked
Returns
True if the object is part of an original prefab

◆ LoadLevelAsync()

static AsyncOperation AC.UnityVersionHandler.LoadLevelAsync ( int  sceneNumber,
string  sceneName = "" 
)
static

Loads the scene asynchronously.

Parameters
sceneNumberThe index number of the scene to load.
sceneNameThe name of the scene to load. If this is blank, sceneNumber will be used instead.
Returns
The generated AsyncOperation class

◆ ObjectIsInActiveScene() [1/2]

static bool AC.UnityVersionHandler.ObjectIsInActiveScene ( string  gameObjectName)
static

Checks if a suppplied GameObject is present within the active scene.

Parameters
gameObjectNameThe name of the GameObject to check for
Returns
True if the GameObject is present within the active scene.

◆ ObjectIsInActiveScene() [2/2]

static bool AC.UnityVersionHandler.ObjectIsInActiveScene ( GameObject  gameObject)
static

Checks if a suppplied GameObject is present within the active scene. The GameObject must be in the Hierarchy at runtime.

Parameters
gameObjectThe GameObject to check for
Returns
True if the GameObject is present within the active scene, or DontDestroyOnLoad.

◆ ObjectIsInScene()

static bool AC.UnityVersionHandler.ObjectIsInScene ( GameObject  gameObject,
int  sceneIndex 
)
static

Checks if a suppplied GameObject is present within a given scene. The GameObject must be in the Hierarchy at runtime.

Parameters
gameObjectThe GameObject to check for
sceneIndexThe build index of the scene
Returns
True if the GameObject is present within the given scene, or DontDestroyOnLoad.

◆ OpenScene() [1/2]

static void AC.UnityVersionHandler.OpenScene ( string  sceneName,
bool  forceReload = false,
bool  loadAdditively = false 
)
static

Loads a scene by name.

Parameters
sceneNameThe name of the scene to load
forceReloadIf True, the scene will be re-loaded if it is already open.
loadAdditivelyIf True, the scene will be loaded on top of the active scene (Unity 5.3 only)

◆ OpenScene() [2/2]

static void AC.UnityVersionHandler.OpenScene ( int  sceneNumber,
bool  forceReload = false,
bool  loadAdditively = false 
)
static

Loads a scene by index number, as listed in the Build Settings.

Parameters
sceneNumberThe index number of the scene to load, as listed in the Build Settings
forceReloadIf True, the scene will be re-loaded if it is already open.
loadAdditivelyIf True, the scene will be loaded on top of the active scene (Unity 5.3 only)

◆ Perform2DOverlapCircle()

static int AC.UnityVersionHandler.Perform2DOverlapCircle ( Vector2  point,
float  radius,
Collider2D []  results,
LayerMask  layerMask 
)
static

Performs a Physics2D.OverlapCircle on Triggers in the scene.

Parameters
pointThe position of the circle's centre
radiusThe radius of the circle
resultsAn array of results
layerMaskThe LayerMask to act upon
Returns
The result of the Physics2D.OverlapCircle

◆ Perform2DOverlapPoint()

static int AC.UnityVersionHandler.Perform2DOverlapPoint ( Vector2  point,
Collider2D []  results,
LayerMask  layerMask 
)
static

Performs a Physics2D.OverlapPoint on Triggers in the scene.

Parameters
pointThe position of the point
resultsAn array of results
layerMaskThe LayerMask to act upon
Returns
The result of the Physics2D.OverlapPoint

◆ Perform2DRaycast() [1/2]

static RaycastHit2D AC.UnityVersionHandler.Perform2DRaycast ( Vector2  origin,
Vector2  direction,
float  length,
LayerMask  layerMask 
)
static

Performs a Physics2D.Raycast on Triggers in the scene.

Parameters
originThe ray's origin
directionThe ray's direction
layerMaskThe LayerMask to act upon
Returns
The result of the Physics2D.Raycast

◆ Perform2DRaycast() [2/2]

static RaycastHit2D AC.UnityVersionHandler.Perform2DRaycast ( Vector2  origin,
Vector2  direction,
float  length 
)
static

Performs a Physics2D.Raycast on Triggers in the scene.

Parameters
originThe ray's origin
directionThe ray's direction
lengthThe ray's length
Returns
The result of the Physics2D.Raycast

◆ PutInFolder()

static bool AC.UnityVersionHandler.PutInFolder ( GameObject  ob,
string  folderName 
)
static

Places a supplied GameObject in a "folder" scene object, as generated by the Scene Manager.

Parameters
obThe GameObject to move into a folder
folderNameThe name of the folder scene object
Returns
True if a suitable folder object was found, and ob was successfully moved.

◆ SetCursorVisibility()

static void AC.UnityVersionHandler.SetCursorVisibility ( bool  state)
static

Sets the visiblity of the cursor.

Parameters
stateIf True, the cursor will be shown. If False, the cursor will be hidden."

◆ SetWindowTitle< T >()

static void AC.UnityVersionHandler.SetWindowTitle< T > ( window,
string  label 
)
static

Sets the title of an editor window (Unity Editor only).

Parameters
windowThe EditorWindow to affect
labelThe title of the window
Type Constraints
T :EditorWindow 

Property Documentation

◆ CursorLock

bool AC.UnityVersionHandler.CursorLock
staticgetset

The 'lock' state of the cursor.