• Manual
  • Scripting API
Show / Hide Table of Contents
  • Introduction
  • How To Install
  • Runtime Objects
    • Creating Runtime Objects
    • Runtime Object Properties
  • Events
    • Event Objects
    • Event Listeners
    • Hello World Example
  • Runtime Items
    • Value Items
    • Reference Items
  • Runtime Lists
    • Value Lists
    • Reference Lists
  • Populators
  • State Machines
    • Using State Machines
    • State Machine Controllers
    • Using State Machine Controllers
  • Versioning Your Apps
  • Modular Scene Loading
  • Attributes
  • License
  • Advanced Topics
    • Settings
    • Why The Resources Folder?
    • Strings as Value Types?
    • Extending The Framework

Reference Items

ReferenceItems are a kind of RuntimeItem that are designed to handle reference types like strings and GameObjects. Below is an example of a GameObjectReference which can be created via "Create > Runtime Objects > Reference > Item > GameObject". All ReferenceItems have a reference property which actually contains the reference in question.

Figure2

There are some limitations with ReferenceItems. It's mainly due to the fact that, in Unity, scene objects can maintain references to assets outside of play mode, but assets cannot maintain references to scene objects outside of play mode. So unless your ReferenceItem is storing a reference to another asset like a prefab, it will not be possible for it to go into play mode with a reference already set. This means you'll need to set the reference yourself during runtime.

However, you can also use these objects to store a direct reference to another asset instead of referencing an object in your scene during runtime. To do this, simply drag in your asset reference and be sure to check the forAssetReferencingOnly box so that this RuntimeObject will ignore all calls for clearing and resetting its data. This will ensure that your reference persists both in and out of playmode.

This feature is especially useful for referencing a prefab that you need to access in many parts of your code. Naturally, you won't need to use any populators when using these objects in this way.

  • Improve this Doc
Back to top Generated by DocFX