How can i use static function in ScriptableObject?

The Error will be testtt,error cs0120 an object reference is required for the non-static field method or property,please help…

public class basic_attack : ScriptableObject
{
    public void Skill_active()
        {
        testt.activeskill();
        }

}

    public class testt :MonoBehaviour
    {
        
        public static void activeskill()
        {
            StartCoroutine(testtt());
        }

        public IEnumerator testtt()
        {
           
                yield return new WaitForSeconds(1.0f);
                
            
        }
    }

I believe you need to make your testt class a public static class if you’re going to have a static method in it. So it should be

public static class testt :MonoBehaviour
{

     public static void activeskill()
     {
         StartCoroutine(testtt());
     }

sorry about the formatting. I’m not terribly familiar with unity answers markup yet

  1. Use dontdestroyobject() to the target object that u want to pass between scenes.
  2. Make the target object a singleton
  3. For other objects which want to get the reference of the target object, I will use FindObjectOfType() in the Start() to get the reference.

Let me know if anyone needs detailed code.

Scriptable Objects [SO] are meant to specifically store data. They aren’t meant to store any kind of actual functions, though you can use the SO to set and store data for your monobehaviours.


Unity Manual - Scriptable Objects

Here’s a link to Unity’s definition and very simple example of how scriptable objects are used. This next link is to a video that Brackeys made explaining Scriptable Objects, their benefits, and how they’re used in game development.

Brackeys’ Scriptable Objects video


I hope this information helped!