Skip to content

Setup Guide

Vincent edited this page Feb 12, 2020 · 8 revisions

Installation

Download and install ETS straight from the Unity Asset Store. (Coming soon)
or
Download from releases and extract the contents into your Unity project's assets folder.

The ETS folder should contain an /Editor folder and two .cs files.

Scene Setup

Add the EaseTransitions.cs script anywhere into the scene.

Editor Window Setup

Open the editor window using the toolbar at the top: [Tools/Ease Transitions Editor].


Just like any other window in Unity, it can be moved and docked.

The editor window will initially be empty, requesting a data file.
The data file is created just like any other asset: [Create/Ease Transitions Data]


This data file will store groups, objects, and transition values for the editor window.
It does not execute any transitions, and is only used to save data for the editor window.
It is recommended to keep these files in the /Editor folder as it is not needed during runtime.

The file then can be inserted into the editor window.


Further usage documentation on the editor window can be found here.

Script Setup

Using the editor window, the user can export templated code that will automatically setup and initialize a dictionary of tObjects.

Code Template

[SerializeField] private EaseTransitions ease;
private Dictionary<string, TransitionObject> tObjects;

private void FindEaseTransitionsClass()
{
	EaseTransitions[] eases = FindObjectsOfType<EaseTransitions>();

	if (eases.Length == 0)
	{
		Debug.LogError("EaseTransitions script not found in scene");
		return;
	}
	else if (eases.Length > 1)
		Debug.LogWarning("Multiple EaseTransitions scripts found in scene, it is recommended to only have one");

	ease = eases[0];
}

private void SetTObjectsList()
{
	tObjects = new Dictionary<string, TransitionObject>();
	/*
	Set and add tObjects to dictionary here.
	For Example: SetTObject("Object 1");
	
	If exporting from the editor window, this will be automatically filled out.
	*/
}
private void SetTObject(string name)
{
	if (tObjects.ContainsKey(name))
		return;

	GameObject gameObject = GameObject.Find(name);
	if (gameObject == null)
	{
		Debug.LogError("GameObject \"" + name + "\" not found");
		return;
	}

	tObjects.Add(name, new TransitionObject(gameObject));
}

private void Start()
{
	FindEaseTransitionsClass();
	SetTObjectsList();
}

But without using the editor window, it is still easy to setup transition objects.
Users looking for further customization and optimization of the code can look below for steps to setup ETS manually.


Any script using ETS will need to declare usage at the top.

using EaseTransitionsSystem;


The EaseTransitions script needs to be referenced.
Create a variable and drag the GameObject containing EaseTransitions script into the variable field.

[SerializeField] private EaseTransitions ease;


Each GameObject being transitioned needs to be linked to a TransitionObject variable.
Creating a TransitionObject is done exactly the same way as creating other objects but with a GameObject parameter.

GameObject gameObject = GameObject.Find("Some GameObject");
TransitionObject transitionObject = new TransitionObject(gameObject);


The TransitionObject can then have its values transitioned with SetTransition().

transitionObject.SetTransition(TransformFields.PositionZ, EaseFunctions.Cubic, EaseDirection.Out, 2.5f, 0f, 100f);


To transition simple float numbers that are not linked to a GameObject component,
A TransitionValue can be created and then be set with a transition.

tValue = new TransitionValue();
tValue.SetTransition(EaseFunctions.Quadratic, EaseDirections.InOut, 2.5f, 0f, 30f, 10f);


And then the tValues's current value can be accessed with it's current variable

float myFloat = tValue.current;


For more advanced code usage, visit the scripting API.

You can’t perform that action at this time.