Adventure Creator  1.79.1
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2022
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 Perform2DRaycasts (ref RaycastHit2D[] hits, Vector2 origin, Vector2 direction, float length, LayerMask layerMask)
 
static int GetSceneIndexFromGameObject (GameObject _gameObject)
 Gets the buld index of the scene that a given GameObject is in. More...
 
static string GetSceneNameFromGameObject (GameObject _gameObject)
 Gets the name of 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 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 string GetCurrentSceneName ()
 Gets the name of the active scene, if multiple scenes are being edited. More...
 
static void NewScene ()
 
static bool OpenScene (string sceneName)
 
static void SaveScene ()
 
static bool SaveSceneIfUserWants ()
 
static bool ObjectIsInActiveScene (string gameObjectName, bool persistentIsValid=true)
 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 GameObject GetPrefabStageRoot ()
 
static void CustomSetDirty (Object _target, bool force=false)
 
static string GetCurrentSceneFilepath ()
 
static bool ShouldAssignPrefabConstantID (GameObject gameObject)
 
static bool ObjectIsInActiveScene (GameObject gameObject, bool persistentIsValid=true)
 Checks if a suppplied GameObject is present within the active 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. More...
 
static T GetOwnSceneInstance< T > (GameObject gameObject)
 Gets a Behaviour that is in the same scene as a given GameObject. More...
 
static T GetSceneInstance< T > (UnityEngine.SceneManagement.Scene scene)
 

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.

◆ 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.

◆ GetCurrentSceneName()

static string AC.UnityVersionHandler.GetCurrentSceneName ( )
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.

◆ GetKickStarterComponent< T >()

static T AC.UnityVersionHandler.GetKickStarterComponent< T > ( )
static

Finds the correct instance of a component required by the KickStarter script.

Type Constraints
T :Behaviour 

◆ 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

◆ 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 

◆ GetSceneIndexFromGameObject()

static int AC.UnityVersionHandler.GetSceneIndexFromGameObject ( GameObject  _gameObject)
static

Gets the buld index of the scene that a given GameObject is in.

Parameters
_gameObjectThe GameObject in the scene
Returns
The build index of the scene that a given GameObject is in.

◆ GetSceneNameFromGameObject()

static string AC.UnityVersionHandler.GetSceneNameFromGameObject ( GameObject  _gameObject)
static

Gets the name of the scene that a given GameObject is in.

Parameters
_gameObjectThe GameObject in the scene
Returns
The name of 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

◆ ObjectIsInActiveScene() [1/2]

static bool AC.UnityVersionHandler.ObjectIsInActiveScene ( GameObject  gameObject,
bool  persistentIsValid = true 
)
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
persistentIsValidIf True, then objects marked as "DontDestroyOnLoad" will also be valid
Returns
True if the GameObject is present within the active scene

◆ ObjectIsInActiveScene() [2/2]

static bool AC.UnityVersionHandler.ObjectIsInActiveScene ( string  gameObjectName,
bool  persistentIsValid = true 
)
static

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

Parameters
gameObjectNameThe name of the GameObject to check for
persistentIsValidIf True, then objects marked as "DontDestroyOnLoad" will also be valid
Returns
True if the GameObject is present within the active scene.

◆ Perform2DRaycast() [1/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

◆ Perform2DRaycast() [2/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

◆ 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.

Property Documentation

◆ CursorLock

bool AC.UnityVersionHandler.CursorLock
staticgetset

The 'lock' state of the cursor.