Loosened dependency principle and reference to other script?

So I am very frequently using this code for get reference to other script.

public class A : MonoBehaviour{
  public static A Instance;
  void Awake(){
     Instance = this;
  }
  public string someStr;
}

then in other script, I can use A.Instance.someStr = “dfdf”;

So is this bad inhabit because dependence to other script?

Then how? and what is benefit of it?

well like always it depends :slight_smile:
you know static will make the instance equal for all other entities that acces it.
Your code is halfway a singleton principal in unity.
the short version of how to use this you can see here.

I don’t know well why that wiki’s full singleton implementation is useful.
Isn’t it more simple and neat that above my example? And I don’t have any problem until now.

If you only want to use a single instance of that class, then I at least cannot see much problems with it. The only thing I’m unsure about is that Awake method - if I want to do something similar I usually just either lose the MonoBehaviour and declare the whole class static, or create a bunch of static methods that are returning the stuff I need. But as someone already said, it usually just depends on the situation.