I’ve been wondering about what I should use for interfaces, separate interfaces for each script? Or would it be wiser to put all interfaces in one script and implement them from there?
Based on the code you posted in your comments, you’ve actually defined an interface within another class.
Code works with the idea of ‘scope,’ or levels of access. What you’ve done in made it so the TileInterfaces class is the only one that knows about the canPlantCharge interface.
canPlantCharge should be the top level scope in the file, meaning the entirety of the canPlantCharge.cs file should be
public interface canPlantCharge
{
void PlantCharge();
}
Alternatively, you could make your WallFunctions say:
public class WallFunctions: MonoBehaviour, TileInterfaces.canPlantCharge {
But that is all manner of strange, in my opinion.
More on scope:
public class ScopeExample: MonoBehavior
{
// Everything declared here is at 'class scope'
// which means they can interact with each other.
// This includes fields, methods, and properties.
// Using the 'public' keyword allows other entities
// outside of this class to access certain class scope items
public int a; // accessible from outside the script.
public void Method1()
{
// Everything declared in here is at 'method' or 'local' scope.
// Things here have access to other items defined in this method,
// as well as all things defined at class scope level
a = 10; // valid
int b;
if (true)
{
// variables declared here will 'fall out of scope'
// at the end of this if block. This means you can use
// them between these curly braces, but not after.
// You still have access to local and class scope variables here!
int c;
a = 11; // valid
b = 12; // valid
c = 13; // valid
}
a = 14; // still valid
b = 15; // still valid
c = 16; // NOT valid!
}
public void Method2()
{
// Even though we are at local scope again, we are in a different
// 'local' so things which are declared in Method1 are not accessible here!
int d;
a = 17; // still valid
b = 18; // NOT valid
d = 19; // valid
}
}
Its really up to you. One thing to consider is reusability of the interfaces/script file in other projects.
Unity will not care either way.