- Home /
 
               Question by 
               SaschaDeWaal · May 10, 2016 at 02:29 PM · 
                editorinspectorscriptableobjecteditorwindow  
              
 
              Custom Inspector for ScriptableObject
I want to save some data in a asset file. For this I create a new assest (conflict : ScriptableObject ). This is working but now I want to create a inspector for the asset so we can enter the data. (when you select the file ). But this isn't working. The inspector keept emty when selected.
Can somebody help me? this is my code.
To create the new asset (is working)
 using UnityEngine;
 using UnityEditor;
 using System.IO;
 using System.Collections;
 
 public class ConflictMenu: EditorWindow  {
 
 
     [MenuItem ("Assets/Create/Conflict")]
     public static void  CreateConflict () 
     {
         Conflict conf = new Conflict ();
         string path = AssetDatabase.GetAssetPath (Selection.activeObject);
 
         AssetDatabase.CreateAsset (conf, path + "/new Conflict"); 
     }
 
 }
 using UnityEngine;
 using System.Collections;
 
 
 [System.Serializable]
 public class Conflict : ScriptableObject  {
 
     public string name = "";
 
 }
Conflict (asset)
 using UnityEngine;
 using System.Collections;
 
 
 [System.Serializable]
 public class Conflict : ScriptableObject  {
 
     public string name = "";
 
 }
Inspector
 using UnityEditor;
 using UnityEngine;
 
 [CustomEditor(typeof(Conflict))]
 public class ConflictInspector : Editor {
 
     public override void OnInspectorGUI()
     {
         EditorGUILayout.TextField ("Name");
     }
 
 }
 
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by SaschaDeWaal · May 12, 2016 at 02:37 PM
I called the new file "new Conflict" but I should have call it "new conflict.asset" (added ".asset" to the name)
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                