Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jul 18, 2013 at 01:48 AM by Essential for the following reason:

No resolution

avatar image
0
Question by Essential · Jul 17, 2013 at 09:44 PM · javascripteditor-scriptingexecuteineditmode

Execute unattached script in Edit Mode

This should be pretty simple. I'm trying to draw a sphere around each spawn point in the scene during edit mode but can't seem to get it to work. I put this script into the Editor folder…

 @script ExecuteInEditMode()
 
 function OnDrawGizmos ()
 {
     var spawns = GameObject.FindByTag("SpawnPoints");
     var cc = spawns.transform.childCount;
     for (var i=0; i < cc; i++)
     {
         // Display the spawning radius
         Gizmos.color = Color.white;
         Gizmos.DrawWireSphere ( spawns.transform.GetChild(i).transform.position, 5.0);
     }
 }
Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image markedagain · Jul 17, 2013 at 09:48 PM 0
Share

attach it to an empty gameobject.

avatar image markedagain · Jul 17, 2013 at 09:49 PM 0
Share

and gizmos are only in edit mode anyway, not sure why you need to implicitly tell it to run in edit. unless im misunderstanding the question

avatar image Essential · Jul 17, 2013 at 09:51 PM 0
Share

I was trying to avoid having the script exist in the scene. I don't want it to get included when the project is exported, hence why I'm trying to make it an editor script.

avatar image iwaldrop · Jul 18, 2013 at 01:39 AM 1
Share

OnDrawGizmos is only called on $$anonymous$$onoBehaviours. You need an object in the scene to benefit from it.

avatar image AlucardJay · Jul 18, 2013 at 06:35 AM 1
Share

If you are worried about multiple scripts running in builds, you can use Platform Dependent Compilation : http://docs.unity3d.com/Documentation/$$anonymous$$anual/PlatformDependentCompilation.html

eg : this is one of my gizmo scripts :

 #pragma strict
 
 #if UNITY_EDITOR
 
 function OnDrawGizmos()
 {
     var col : BoxCollider = GetComponent.< BoxCollider >();
     
     if ( col )
     {
         Gizmos.color = Color.red;
         Gizmos.matrix = transform.localToWorld$$anonymous$$atrix;
         Gizmos.DrawCube( col.center, col.size );
     }
 }
     
 #endif

Edit : If you are interested in how optimal this method might be, I just asked a question you may want to follow. Now I'm curious how efficient this may be : http://answers.unity3d.com/questions/495342/questions-about-platform-dependent-compilation.html

Show more comments

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Accessing OnSceneGUI with EditorWindow in JS 1 Answer

Automated prefab script switching? 1 Answer

function Update in edit mode 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

ExecuteInEditMode not working in some scripts 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges