Legacy Documentation: Version 2017.2 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ExposedReference<T0>

struct in UnityEngine

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Creates a type whos value is resolvable at runtime.

ExposedReference is a generic type that can be used to create references to scene objects and resolve their actual values at runtime and by using a context object. This can be used by assets, such as a ScriptableObject or PlayableAsset to create references to scene objects.

#pragma strict
public class CameraSwitcher extends StandardAsset {
    public var theSceneCamera: ExposedReference.<Camera>;
    public override function PrepareFrame(frameData: FrameData) {
        var sceneCamera: var = theSceneCamera.Resolve(frameData.exposedPropertyResolver);
    }
}
using UnityEngine;

public class CameraSwitcher : StandardAsset { public ExposedReference<Camera> theSceneCamera;

public override void PrepareFrame(FrameData frameData) { var sceneCamera = theSceneCamera.Resolve(frameData.exposedPropertyResolver); } }

In this example, we have an asset that needs to save a reference to a scene object, in this case a camera. The ExposedProperty generic is used to define the field, and at runtime its actual value is fetched by passing the ExposedPropertyResolver.

Properties

defaultValueThe default value, in case the value cannot be resolved.
exposedNameThe name of the ExposedReference.

Public Methods

ResolveGets the value of the reference by resolving it given the ExposedPropertyResolver context object.

Did you find this page useful? Please give it a rating: