Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SOExampleBehaviour v2
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class SOExampleBehaviour : MonoBehaviour
{
public SOExample test;
public void OnEnable()
{
// find existing instance if needed
if (test == null)
test = Object.FindObjectOfType<SOExample>();
// then instantiate if needed
if (test == null)
test = ScriptableObject.CreateInstance<SOExample>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.