title: Is it possible to create a "global" class instance in Unity?
body: <p>Sorry for the silly question, I'm a newbie in Unity scripting.</p>
  
  <p>I need to create a class instance which it need to be shared and accessed by the components in any scene.</p>
  
  <p>I could easily create a static class and use it in the component scripts, but my class have heavy network and processing, and since I need to process it only once, it would be nice to create only a single instance.</p>
  
  <p>Is it possible to do something similar to that?
  For example:</p>
  
  <pre class="lang-cs prettyprint-override"><code>// The class which I need to create and share
  public class DemoClass {
       MyExampleClass example;
       public DemoClass (){
              example = new MyExampleClass ();
        }
       public MyExampleClass GetClassInstance(){
              return example;
        }
   }
  
  // The "Global Script" which I'll instantiate the class above
  public class GlobalScript{
      MyExampleClass example;
      public void Start(){
           DemoClass demoClass = new DemoClass();
           example = demoClass.GetClassInstance();
       }
  
       public MyExampleClass getExample(){
           return example;
        }
    }
  
    // Script to insert in any component
    public class LoadMyClass : MonoBehaviour {
        public void Start(){
            // this is my main issue. How can I get the class Instance in the GlobalScript?
            // the command below works for Static classes.
            var a = transform.GetComponent&lt;GlobalScript&gt;().getExample(); 
         }
      }
  </code></pre>
  
  <p>Any hint on this would be very appreciated. </p>
  
  <p>Thanks.</p>