Created
April 2, 2015 14:41
-
-
Save snlehton/b867a596df079993873a to your computer and use it in GitHub Desktop.
SOExampleBehaviour v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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