Search Unity

Create object thats only in the editor

Discussion in 'Scripting' started by Nieles, Nov 16, 2011.

  1. Nieles

    Nieles

    Joined:
    Dec 27, 2010
    Posts:
    50
    Is it possible to create a object that is only there in the editor.
    So the object is there when you play the game.

    For instance I want to place spawn points in the editor.
    But the spawnpoint information is saved to an database, and they don't need to be there anymore after I have build the game.

    Is there an easy way to do this?

    I gues I could create an Destroy function on the start function but thats just extra work on loading the game. So it would be better if thet just aren't exported.
     
  2. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
  3. Nieles

    Nieles

    Joined:
    Dec 27, 2010
    Posts:
    50
  4. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    ??
    That than is exactly what you mean. If platform == editor, create dummy objects. Simple.
    That won't be compiled into any other platform but UNITY_EDITOR.
    Did you at least read whats in the docs' page?!

    If you want scripts that run in Editor mode without hitting the Play button, you'll need to create editor tools for that.
    http://unity3d.com/support/documentation/Components/gui-ExtendingEditor.html
     
    Last edited: Nov 16, 2011
  5. Nieles

    Nieles

    Joined:
    Dec 27, 2010
    Posts:
    50
    Yes I have read the docs. But I don't want to create dummies when running any platform.
    The dummies must be there and they get saved in the scene, however they must not exist when playing the game.
    They are just helpers for me to easily edit database values and visualize them in the editor.
    But the code for these spawn points is handled by server software so the unity client release doesn't have anything to do with them.
    If the doc says how to do this then I don't get it :) Because what I make up from that doc is that you can run specific code only on a specific platform. But these helper dummies must not exist on any platform so they don't need to run any code. Just the editor (not even when running the editor!)