using UnityEngine; using UnityEditor; using Unity.Tutorials.Core.Editor; /// /// Implement your Tutorial callbacks here. /// [CreateAssetMenu(fileName = DefaultFileName, menuName = "Tutorials/" + DefaultFileName + " Instance")] public class TutorialCallbacks : ScriptableObject { /// /// The default file name used to create asset of this class type. /// public const string DefaultFileName = "TutorialCallbacks"; /// /// Creates a TutorialCallbacks asset and shows it in the Project window. /// /// /// A relative path to the project's root. If not provided, the Project window's currently active folder path is used. /// /// The created asset public static ScriptableObject CreateAndShowAsset(string assetPath = null) { assetPath = assetPath ?? $"{TutorialEditorUtils.GetActiveFolderPath()}/{DefaultFileName}.asset"; var asset = CreateInstance(); AssetDatabase.CreateAsset(asset, AssetDatabase.GenerateUniqueAssetPath(assetPath)); EditorUtility.FocusProjectWindow(); // needed in order to make the selection of newly created asset to really work Selection.activeObject = asset; return asset; } /// /// Example callback for basic UnityEvent /// public void ExampleMethod() { Debug.Log("ExampleMethod"); } /// /// Example callbacks for ArbitraryCriterion's BoolCallback /// /// True if the GameObject Foo exist public bool DoesFooExist() { return GameObject.Find("Foo") != null; } /// /// Implement the logic to automatically complete the criterion here, if wanted/needed. /// /// True if the auto-completion logic succeeded. public bool AutoComplete() { var foo = GameObject.Find("Foo"); if (!foo) foo = new GameObject("Foo"); return foo != null; } }