#Asset creation
1 messages · Page 1 of 1 (latest)
The path you are trying to create a new asset at is exactly the same, that is why you are getting the errors. When creating assets it is best to use the path =AssetDatabase.GenerateUniqueAssetPath(path); to make sure it is a unique path.
You also are trying to save the same instance of the asset. If you want a create a new instance then you use Object.Instatiate(..)
Or for your case, you can just use AssetDatabase.CopyAsset(..)
All AssetDatabase.CreateAsset(..) does is basically create a file on disk for the UnityEngine.Object instance you give it (It does other stuff, but that is all that is important atm).
im not trying to copy the same asset, im making a new asset for each inputAction
that needs to have the inputAction assign to the InputAction property of it
What is InputAction?
in the middle
Okay so you are using the input system. Why are you creating assets for the InputActions?
sry i was afk, im creating a asset for the asset store that wraps the new input into the old one
and im using SO to subscribe and to have a reference to the action
What...? Why would you do that, that sounds like the worst of both words if I am understanding you properly. I mean to each their own, but still.
If the InputActions are SOs then they are already saved as assets, so you don't need to make them assets
I want to generate so based on the input actions located here
Yeah those are already assets
You can use a InputActionReference to reference them
Every SO has a field for the input action
Ik
The field is a reference
But i want to attach that specific input action to the field when it is generated
What field? When what is generated?
The generate function from above generates input data files in a directory
That input data is a scriptable object with a serialize inputactionreference
U can see a for loop in the generate function
Oh I see I think
Thats where all the input action from the input action asset are created
That's my bad, I misread it
Np
So what is the current problem?
Whem the so is generated i need to attach the input action(inside foreach) to the input action field of it
Okay, first of all, you are creating multiple assets of the same instance. Is that what you want?
Simply doing _inputDataInstance.InputActionRef = inputAction; before creating the asset is all that is requried
might have to set the object dirty after setting the value
Set the object dirty?
EditorUtility.SetDirty(inputDataInstance);
What does that
It tells Unity that the object has changed
So it knows it needs to be saved
Sure thing!
it didnt work
i figure out
im dumb af
[SerializeField] private InputActionReference inputAction;
public InputAction InputAction { get; set; } ```
i was setting the InputAction property to the correct input action
but forgot to set the inputactionreference
...
sry for all the time wasted with me