#Using Arrays with Scriptable Object Interfaces

1 messages · Page 1 of 1 (latest)

oak zinc
#

Hi!

This should be pretty simple, but I cannot find anything online to help me. I'm using an Interface with 2 kinds of Scriptable Objects to store similar sets of information, and I wanted to have an array as one of the Interface Members.

How can I fill out:
public MoveBase[] Moves{get;}

To have 4 objects from an array I set in the scriptable object assigned to the same positions of the array?

I can share more code if this explanation isn't sufficient, thanks!

warm tundra
#

Interface does not implement methods or variables, it only tells what methods to implement. Actual implementation is in the class that uses the interface. https://www.dotnetperls.com/interface

oak zinc
#

Yes, sorry, the line I'm trying to figure out is in the classes

oak zinc
#

To clarify, I have a have an Interface for characters in combat, and a ScriptableObject Class for Players and Enemies. I have an array in the Interface for the equipped moves of the character, and I'm unsure how to properly Implement/Assign that within each class, as I can't just write

public MoveBase[] Moves{get{return equippedMoves[]};}

warm tundra
#

Not sure where the confusion is. If you are looking how to use property with interface there's an example in the link as well. You can use it to pass and receive an entire array.

#

If you need to assign just one value to the array, use a method with an index and value in the parameters.

#

Again make sure you are not confusing signature of the method/parameter in the interface from actual implementation. See the examples.

oak zinc
#

My complication is just with using a property that is an array. I've got lots of other ones that are working fine, but the array doesn't work because it expects a value, and I can't do a 'for' loop in the declaration, or specify a size in variable declaration. I'm sure there is a simple way to assign them, but I do not know it, and it doesn't seem to be covered in the link you sent