Last active
          February 12, 2019 11:34 
        
      - 
      
 - 
        
Save simonwittber/60a50efc7813a6a0576c569a1c5cbd6c to your computer and use it in GitHub Desktop.  
    Using Unity's ScriptableWizards as Dialogs in CustomEditors.
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | public class AddThingToSomeScriptableObject : ScriptableWizard | |
| { | |
| internal SomeScriptableObject someScriptableObject; | |
| public SomeThing someThing; | |
| void OnCreateButton() | |
| { | |
| //add someThing to someScriptableObject. | |
| } | |
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
  | [CustomEditor(typeof(SomeScriptableObject))] | |
| public class SomeScriptableObjectEditor : Editor | |
| { | |
| public override void OnInspectorGUI() | |
| { | |
| var someScriptableObject = target as SomeScriptableObject; | |
| if (GUILayout.Button("Add a New Thing")) | |
| { | |
| var wizard = ScriptableWizard.DisplayWizard<AddThingToSomeScriptableObject>("New Thing", "Create"); | |
| wizard.someScriptableObject = someScriptableObject; | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment