#Asset creation

1 messages · Page 1 of 1 (latest)

proper willow
#

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).

boreal sluice
#

that needs to have the inputAction assign to the InputAction property of it

boreal sluice
#

in the middle

proper willow
#

Okay so you are using the input system. Why are you creating assets for the InputActions?

boreal sluice
#

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

proper willow
#

If the InputActions are SOs then they are already saved as assets, so you don't need to make them assets

boreal sluice
proper willow
#

You can use a InputActionReference to reference them

boreal sluice
#

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

proper willow
#

What field? When what is generated?

boreal sluice
#

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

proper willow
#

Oh I see I think

boreal sluice
#

Thats where all the input action from the input action asset are created

proper willow
#

That's my bad, I misread it

boreal sluice
#

Np

proper willow
#

So what is the current problem?

boreal sluice
#

Whem the so is generated i need to attach the input action(inside foreach) to the input action field of it

proper willow
#

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

proper willow
#

At a glance that looks good

#

Are you still having problems?

boreal sluice
#

Yep

#

The input action field is null

proper willow
#

might have to set the object dirty after setting the value

boreal sluice
#

Set the object dirty?

proper willow
#

EditorUtility.SetDirty(inputDataInstance);

boreal sluice
#

What does that

proper willow
#

It tells Unity that the object has changed

boreal sluice
#

Do

#

Oh

proper willow
#

So it knows it needs to be saved

boreal sluice
#

Ill try that after i eat

#

Thank you for your help

proper willow
#

Sure thing!

boreal sluice
#

it didnt work

boreal sluice
#

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