Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to declare classes that are in the editor folder?

Discussion in 'Scripting' started by GabeF, Jan 4, 2014.

  1. GabeF

    GabeF

    Joined:
    Sep 28, 2012
    Posts:
    38
    Hi Everyone,

    I need to utilize a class in the editor folder during postprocessmodel.

    It should be fine because both of my C# scripts are in the same directory. I have 1 processing custom variables, and the other setting up the scene based on those variables.

    But I for the life of me can't figure out how to use Class B within Class A.

    I even created a namespace for it, but looking at the forums, people say I can't use the script unless it's part of a component on a gameObject?

    Well I don't have a game object as yet and I sure as hell want to avoid putting an editor only script on a gameobject that won't be used at runtime.

    Any thoughts?
     
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Would help to have some example of what you mean.

    If your "script" is in the Editor folder, why does it derive from MonoBehaviour?

    If it doesn't derive from MonoBehaviour, you can just create an instance of it like any other C# object;

    Code (csharp):
    1.  
    2. MyType instance = new MyType();
    3.