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 post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by babasuter · Apr 26, 2014 at 04:10 PM · instantiategridtreesbillboardedit mode

Instantiate in edit mode, utilizing billboarding

I want to put a grid of objects (cornstalks) on the terrain in edit mode (as if a farmer had planted North/South, then again East/West) so that I can delete some in a pattern, leaving a corn maze. Creating the grid in play mode doesn't allow me to edit the maze paths out. When I run the "DO CORN" from the context menu (see below), the _sphere's script is called successfully (confirmed by the debug.log), but nothing gets placed on the terrain in edit mode. What am I missing?

I'm not sure this is possible to do while still using the "billboarding" that Mass Place Trees uses, as I'm aware that just placing thousands of cornstalk objects will lag horribly. If I have to brush in the whole terrain of corn stalk "trees" I will, but a properly planted corn field grid would be much cooler. I'm a hs teacher dabbling in Unity, so these scripts are cobbled together.

I've tried so far:

  1. Using a context menu to call another script (works as indicated by debug.log)

  2. The second script does create the desired grid, but only in play mode.

  3. Various combinations of the "execute in edit mode" on the second script.

Here's some images of my inspector. obj1_inspector obj2_inspector

My 2 scripts:

MakeCorn.js

 // JavaScript
 //@script ExecuteInEditMode()
 
 var mySphere : GameObject;
 function Start () {
 
     Debug.Log ("I found the MakeCorn script and theMakeCornFunc function!");
     for (var z = 10; z < 50; z+=2) {
         for (var x = 10; x < 50; x+=2) {
             yield WaitForSeconds(.01);
             var corn = Instantiate(mySphere);
             mySphere.transform.position = Vector3 (x, 0, z);
         }
     }
 }     



MyContxtMenu.js

 var objectwScript : GameObject;
 //@script ExecuteInEditMode()
 @ContextMenu ("Do CORN")
 function DoSomething () {
     
     //Debug.Log ("I'm trying to access the instantiate corn script");
     objectwScript.GetComponent(MakeCorn).Start();
     
 }

rip_inspector.png (30.7 kB)
sphere_inspector.png (29.5 kB)
Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 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 avatar image avatar image

Related Questions

Transparent shader (water) showing over billboard trees 4 Answers

tree billboard are just pixels with terrain billboard 0 Answers

How can I offset blocks in a tower to build a Jenga-like structure? 0 Answers

remove and replace item in grid 1 Answer

Tree billboards not displaying correctly. 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