I have created a very basic Tetris inventory system using debug.drawlines and im wondering how i could make specific scriptable objects that have data such as the name, the size of the vector2 and its sprite prefab. Heres what ive done if you need code to look at just ask.
Hi @HC2010,
Thats actually pretty neat! Great job on getting that working with debug lines.
As for Scriptable Objects, I’d start by looking at the documentation here:
The first code example there is probably what you’re looking for. Assuming you want to create scriptable object assets in your project, you can use the CreateAssetMenu
attribute to do so. Something like this:
using UnityEngine;
[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/TetrisBlock , order = 1)]
public class TetrisBlock : ScriptableObject
{
public string displayName;
public Vector2 size;
public Sprite sprite;
}
So what i managed to get so far is one scriptable object to work with size, but i cant seem to add any sprites! I also dont want it to be on the world 0 , 0 but on my canvas. Can you help me with the Positioning of the grid and sprites?
I need a little more context to help you out. It seems like you’re trying to solve the bigger picture design, but we on the forums don’t really know what your project is or what you’re trying to achieve.
I suggest you break down your current goal into concrete steps, and if you’re running into a specific problem, post here with a clear context, what the problem is, and what you’ve tried to do to solve it.
I’ve found this to be a really good guide in the past:
So for instance:
What do you mean by « I can’t seem to add sprites ». Are you having trouble assigning sprite references to your scriptable object, or are you having trouble making the sprite appear on your Tetris grid system?
The latter would need a lot more context:
- What exactly are you trying to accomplish?
- What code are you trying to run?
- What exceptions or errors are you running into?
Ok ill try that thank you