- Home /
Is it bad practice to have method definitions in a Scriptable Object?
Hi all,
As the title suggests, I'm wondering if there's any reason why I shouldn't define methods within a scriptable object?
Let's say I'm implementing the Command Design Pattern with scriptable objects, which has data and an implementation on how to execute the command.
// Assume Command is a scriptable object
public class SayCommand : Command
{
public string actor;
public string sentence;
// Simple implementation just for demonstration purposes
// This would usually reference another object and call that object's Say() method
public void Execute()
{
Debug.Log(actor + " said: " + sentence);
}
}
For the conversation system that I'm working on, this seems to be an ideal way for me to decouple some of my code by having the command implementation in it's own class as opposed to in a manager object with switch statements.
I've seen people refer to scriptable objects as assets just for storing data, but I haven't seen anyone use methods within scriptable objects or give a reason why methods shouldn't be used in them.
Is this bad practice and if so, why?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Reliable way to detect when the game starts playing on a ScriptableObject? 1 Answer
Distribute terrain in zones 3 Answers
How to Update ScriptableObject 1 Answer