Advanced Reflection

IMPORTANT! - The reflection feature is only available in the Professional and Personal Learning Edition (PLE) versions of uScript. If you wish to upgrade your license of uScript to the Professional version, please contact Detox Studios.

 

Reflecting Things That Aren't There

By default uScript will reflect anything that is in the currently loaded scene in the Unity Editor. There are times however that you may want to use reflected nodes and properties for things that are not in the scene at design-time but do appear once the game is running (like maybe assigning a component to a GameObject at run-time). In order to do this in uScript, you can assign the things you wish to force to be reflected by editing the uScriptUserTypes.cs file found in the root of the uScriptProjectFiles folder of your Unity project.

 

To modify the uScriptsUserTypes.cs file, do the following:

 

1. Open the file in your source code editor of choice (Unity used MonoDevelop by default). Just double-click the file in Unity to bring up Unity's default code editor. This file is located in the root of your project's uScriptProjectFiles folder:

 

 

 

2. Once open, you can add Unity objects to be reflected. In this example we will be adding the SpringJoint component, though you can add any valid Unity object type:

 

Note! - if you wish to add more than one Type to be reflected, please assign them to the same Type string variable and use commas to separate them like this:

 

 

 

3. Save the file and return to Unity. If the file was edited properly, Unity will compile it. Once it is compiled close and re-open uScript (if uScript is already open, you will need to close it first) to see the additional items you have specified to be reflected. Like all reflected nodes, the new nodes will appear under the Reflected ( ) section of the Toolbox:

 

 

Note! - You will only be able to use these newly reflected nodes on GameObjects you are certain contain the reflected item when you plan to use it at runtime. As always, make sure you have assigned the Instance property for any reflected node to the GameObject you wish to refer to when accessing the specific instance of a reflected item.

 

 

Reflecting Other Middleware

In order to reflect most other Unity middleware in uScript, you will need to either define the item to be reflected (as shown above in "Reflecting Things That Aren't There"), or by assigning the middleware script to a GameObject. In this example we will show you how to reflect iTween as an example.

 

1. Install the middleware into your Unity project.

 

2. Create a new, empty GameObject (ours is called iTweenController in this example) and assign the middleware's script file to it:

 

 

 

3. Now open the uScript Editor and look for the middleware to be reflected in the Reflected ( ) section of the Toolbox:

 

 

 

Note! - Some middleware may require custom nodes to be created to get the most out of using it in uScript. Some middleware providers (such as NGUI for example) have created nodes to better integrate there middleware with uScript. We recommend that you contact the middleware author as well as stop by the uScript forum to see if there has been custom nodes created for the specific middleware you are using.