Auto add references when put in certain folders?
-
- Posts: 18
- Joined: Sat Jul 15, 2023 2:58 am
Auto add references when put in certain folders?
So my game doesn't need much saved besides SOs and other referenced assets. So I have the auto-add things from the scene turned off for my Easy Save Manager.
I was wondering if there was a way to setup something where whenever I created a new asset in a certain folder in my project, it would add it to the Reference Manager.
For example, I have food SOs. Their data is stuff like name, cost, mesh, material, etc. I make new ones all the time. The player has an inventory of sorts that gets filled with the food they have purchased and picked up. That list needs to get saved. So In order for it to save and load, those food SO items need to be in the reference section on the Manager. I'd rather not add them one by one every time I add a new one. Is there any way to automate this?
Thanks
I was wondering if there was a way to setup something where whenever I created a new asset in a certain folder in my project, it would add it to the Reference Manager.
For example, I have food SOs. Their data is stuff like name, cost, mesh, material, etc. I make new ones all the time. The player has an inventory of sorts that gets filled with the food they have purchased and picked up. That list needs to get saved. So In order for it to save and load, those food SO items need to be in the reference section on the Manager. I'd rather not add them one by one every time I add a new one. Is there any way to automate this?
Thanks
Re: Auto add references when put in certain folders?
Hi there, and thanks for getting in contact.
You can ask Easy Save to watch folders for references by the path (relative to the projects folder, e.g. Assets/MyFolder/) to the Reference Folders list in Tools > Easy Save 3 > Settings. However, this is part of the automatic reference updating system which you've disabled.
The only alternative would be to write your own Editor script which calls the manager's hidden AddDependenciesFromFolders() method in order for this to be called, perhaps using PlayModeStateChanged and PlayModeStateChange.ExitingEditMode to ensure that it's called automatically before you enter playmode.
All the best,
Joel
You can ask Easy Save to watch folders for references by the path (relative to the projects folder, e.g. Assets/MyFolder/) to the Reference Folders list in Tools > Easy Save 3 > Settings. However, this is part of the automatic reference updating system which you've disabled.
The only alternative would be to write your own Editor script which calls the manager's hidden AddDependenciesFromFolders() method in order for this to be called, perhaps using PlayModeStateChanged and PlayModeStateChange.ExitingEditMode to ensure that it's called automatically before you enter playmode.
All the best,
Joel
-
- Posts: 18
- Joined: Sat Jul 15, 2023 2:58 am
Re: Auto add references when put in certain folders?
ah ok interesting. So if I turn the auto update back on, does too many things inside the reference manager slow the game down at all?Joel wrote: ↑Sat Jul 15, 2023 8:32 am Hi there, and thanks for getting in contact.
You can ask Easy Save to watch folders for references by the path (relative to the projects folder, e.g. Assets/MyFolder/) to the Reference Folders list in Tools > Easy Save 3 > Settings. However, this is part of the automatic reference updating system which you've disabled.
The only alternative would be to write your own Editor script which calls the manager's hidden AddDependenciesFromFolders() method in order for this to be called, perhaps using PlayModeStateChanged and PlayModeStateChange.ExitingEditMode to ensure that it's called automatically before you enter playmode.
All the best,
Joel
Re: Auto add references when put in certain folders?
The reference manager just keeps references to things which are already in your scene (or things you've told it to keep references to) so that it can assign a persistent ID to them. It uses a Dictionary underneath so the number of references won't affect performance.
All the best,
Joel
All the best,
Joel
-
- Posts: 18
- Joined: Sat Jul 15, 2023 2:58 am
Re: Auto add references when put in certain folders?
How do I access this AddDependenciesFromFolders() method? Can't find it anywhere? Even did CTRL + F for whole project.Joel wrote: ↑Sat Jul 15, 2023 8:32 am Hi there, and thanks for getting in contact.
You can ask Easy Save to watch folders for references by the path (relative to the projects folder, e.g. Assets/MyFolder/) to the Reference Folders list in Tools > Easy Save 3 > Settings. However, this is part of the automatic reference updating system which you've disabled.
The only alternative would be to write your own Editor script which calls the manager's hidden AddDependenciesFromFolders() method in order for this to be called, perhaps using PlayModeStateChanged and PlayModeStateChange.ExitingEditMode to ensure that it's called automatically before you enter playmode.
All the best,
Joel
Re: Auto add references when put in certain folders?
Hi there,
Are you using the latest version of Easy Save?
Also be aware that the method won't come up in code completion because as mentioned previously, it's hidden.
All the best,
Joel
Are you using the latest version of Easy Save?
Also be aware that the method won't come up in code completion because as mentioned previously, it's hidden.
All the best,
Joel
-
- Posts: 18
- Joined: Sat Jul 15, 2023 2:58 am
Re: Auto add references when put in certain folders?
Hi there,
It's hidden but that doesn't mean you can't use the method, it just means it won't appear in code completion. So for example this code would work, even though the method doesn't appear in code completion:
If that doesn't work for you then I would double check you're using the latest version of Easy Save.
All the best,
Joel
It's hidden but that doesn't mean you can't use the method, it just means it won't appear in code completion. So for example this code would work, even though the method doesn't appear in code completion:
Code: Select all
GameObject.Find("Easy Save 3 Manager").GetComponent<ES3ReferenceMgr>().AddDependenciesFromFolders();
All the best,
Joel
-
- Posts: 18
- Joined: Sat Jul 15, 2023 2:58 am
Re: Auto add references when put in certain folders?
So I got this working, but PlayModeStateChange.ExitingEditMode isn't being called lol. All the other changes are, but not that one... So I gotta figure that out. Thanks for the help though!Joel wrote: ↑Mon Jul 17, 2023 2:49 pm Hi there,
It's hidden but that doesn't mean you can't use the method, it just means it won't appear in code completion. So for example this code would work, even though the method doesn't appear in code completion:
If that doesn't work for you then I would double check you're using the latest version of Easy Save.Code: Select all
GameObject.Find("Easy Save 3 Manager").GetComponent<ES3ReferenceMgr>().AddDependenciesFromFolders();
All the best,
Joel
-
- Posts: 18
- Joined: Sat Jul 15, 2023 2:58 am
Re: Auto add references when put in certain folders?
So actually it seems that the references added aren't saved. Like when I open another scene and go back to the other, all the references are gone.Joel wrote: ↑Mon Jul 17, 2023 2:49 pm Hi there,
It's hidden but that doesn't mean you can't use the method, it just means it won't appear in code completion. So for example this code would work, even though the method doesn't appear in code completion:
If that doesn't work for you then I would double check you're using the latest version of Easy Save.Code: Select all
GameObject.Find("Easy Save 3 Manager").GetComponent<ES3ReferenceMgr>().AddDependenciesFromFolders();
All the best,
Joel
Code: Select all
[InitializeOnLoad]
public class EasySave3ManagerEditorFolderWatch
{
static EasySave3ManagerEditorFolderWatch()
{
EditorApplication.playModeStateChanged += StateChanged;
}
static void StateChanged(PlayModeStateChange state)
{
if (state == PlayModeStateChange.ExitingEditMode)
{
ES3ReferenceMgr es3 = GameObject.Find("Easy Save 3 Manager").GetComponent<ES3ReferenceMgr>();
es3?.AddDependenciesFromFolders();
//es3.
}
}
}