N
N
nano_e_t_42019-06-21 19:10:05
Game development
nano_e_t_4, 2019-06-21 19:10:05

How to hang canvas on scriptableObject?

Hello everyone
I got carried away here with unity, I'm making a small ui for the game. And there was a need to add an item, in which there will be fields:
- title,
- image for it
- description (description in the form of text, and background_image, on which the text will hang).
There is no way to add canvas to a scriptable object (when trying to migrate the canvas prefab, it simply does not migrate). Does anyone know how this is done?

public class Item : ScriptableObject
{
    new public string name =  "New Item";
    public Sprite icon = null;
    public Canvas description = null;

}

p/s
The bottom line is that items are on the playing field. When a player approaches an item, it is added to it in the menu. When the user opens the menu, clicks on this item, and a description of the item's functionality pops up

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2019-06-21
@freeExec

You have bad architecture. ScriptableObject is essentially a static data store, and it should not know anything about the game, much less interact with the UI in any way. You need a separate MonoBehaviour that will impersonate the game object, it will interact with the world and know the properties of the Item.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question