您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
44 行
851 B
44 行
851 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class RuntimeAnchorBase<T> : DescriptionBaseSO where T : UnityEngine.Object
|
|
{
|
|
public UnityAction OnAnchorProvided;
|
|
|
|
[Header("Debug")]
|
|
[ReadOnly] public bool isSet = false; // Any script can check if the transform is null before using it, by just checking this bool
|
|
|
|
[ReadOnly] [SerializeField] private T _value;
|
|
public T Value
|
|
{
|
|
get { return _value; }
|
|
}
|
|
|
|
public void Provide(T value)
|
|
{
|
|
if(value == null)
|
|
{
|
|
Debug.LogError("A null value was provided to the " + this.name + " runtime anchor.");
|
|
return;
|
|
}
|
|
|
|
_value = value;
|
|
isSet = true;
|
|
|
|
if(OnAnchorProvided != null)
|
|
OnAnchorProvided.Invoke();
|
|
}
|
|
|
|
public void Unset()
|
|
{
|
|
_value = null;
|
|
isSet = false;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
Unset();
|
|
}
|
|
}
|