Exemple #1
0
 void OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         CarProfiles = AssetDatabase.LoadAssetAtPath(objectPath, typeof(CarProfileList)) as CarProfileList;
     }
 }
 private void OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         CarProfiles = AssetDatabase.LoadAssetAtPath("/Assets/Resources/Shared Data/", typeof(CarProfileList)) as CarProfileList;
         // "/Assets/Resources/Shared Data/"
     }
 }
    public static CarProfileList CreateProfilesList()
    {
        CarProfileList profileList = ScriptableObject.CreateInstance <CarProfileList>();

        AssetDatabase.CreateAsset(profileList, "Assets/Resources/Shared Data/Profile Lists/new car profiles list.asset");
        AssetDatabase.SaveAssets();

        EditorUtility.FocusProjectWindow();

        Selection.activeObject = profileList;
        return(profileList);
    }
Exemple #4
0
 void CreateNewProfileList()
 {
     // There is no overwrite protection here!
     // There is No "Are you sure you want to overwrite your existing object?" if it exists.
     // This should probably get a string from the user to create a new name and pass it ...
     viewIndex   = 1;
     CarProfiles = CreateCarProfileList.CreateProfilesList("CarProfileList");
     if (CarProfiles)
     {
         CarProfiles.profileList = new List <CarProfile>();
         string relPath = AssetDatabase.GetAssetPath(CarProfiles);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Exemple #5
0
    void OpenProfileList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Inventory Item List", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            CarProfiles = AssetDatabase.LoadAssetAtPath(relPath, typeof(CarProfileList)) as CarProfileList;
            if (CarProfiles.profileList == null)
            {
                CarProfiles.profileList = new List <CarProfile>();
            }
            if (CarProfiles)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }