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 /
avatar image
0
Question by MrScrumbles001 · May 24, 2014 at 02:02 AM · scaletreesterrain-treesmass place trees

Mass place trees scale issue

Hello there

I was wondering if anyone knew a way to scale Mass placed trees in the Terrain functions. I am able to scale the trees when I place them manually on the terrain however when mass placing them they only appear as the default size. Manually placing them would be an option if I could increase the brush size much higher than the maximum setting.

I have tried scaling up the tree prefab but it appears to ignore the scale settings.

any help would be highly appreciated

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AlucardJay · May 24, 2014 at 03:26 PM

Here is a script that will randomly scale between two values the trees that are painted on the terrain.

To set this up :

Create a new javascript named ScaleExistingTrees. Use the code below.

Attach the script to the terrain object.

Drag and drop your terrain into the the Inspector.

Set the min and max scale to your liking.

How to use this :

Right-click on the script component in the Inspector, then a drop-down selection box appears. Example :

alt text

Click on Scale Existing Trees, now your trees have been scaled =]

Remove the script from the terrain when you are done.


ScaleExistingTrees.js

 #pragma strict
 
 public var terrain : Terrain;
 
 public var minScale : float = 0.8;
 public var maxScale : float = 1.2;
 
 #if UNITY_EDITOR
 @ContextMenu( "Scale Existing Trees" )
 function ScaleExistingTrees() 
 {
     // check if there is no terrain in the inspector, then use the current active terrain
     if ( !terrain )
     {
         terrain = Terrain.activeTerrain;
     }
     
     // check if maxScale is less than minScale
     if ( maxScale < minScale )
         maxScale = minScale;
     
     // variable for storing random calculated scale
     var rndScale : float;
     
     // store reference of all the current trees
     var treeInstances : TreeInstance[] = terrain.terrainData.treeInstances;
     
     // cycle through each tree
     for ( var t : int = 0; t < treeInstances.length; t ++ )
     {
         // calculate random scale
         rndScale = Random.Range( minScale, maxScale );
         
         // apply to curent tree in array
         treeInstances[t].heightScale = rndScale;
         treeInstances[t].widthScale = rndScale;
     }
     
     // apply treeInstances back to terrain data
     terrain.terrainData.treeInstances = treeInstances;
     
     Debug.Log( "Scaling Trees Complete" );
 }
 #endif


scaleexistingtrees.jpg (30.7 kB)
Comment
Add comment · Show 2 · Share
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 AlucardJay · May 25, 2014 at 04:10 PM 0
Share

How did you go?

avatar image chopsokey · Aug 22, 2014 at 09:24 AM 0
Share

Just found this script, helped me immensely after changing my tree model. $$anonymous$$any thanks!!

avatar image
0

Answer by vfxjex · Mar 01, 2015 at 12:55 AM

if your tree is procedural, and you don't wan't to deal with scripting, check this out. http://forum.unity3d.com/threads/unity-tree-scaling-inside-terrain-no-effect.98774/

Comment
Add comment · Share
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

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

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

Related Questions

Mass Place Trees via runtime script? 1 Answer

Tree sticks through terrain despite collider being same height 0 Answers

"Mass place trees" vs -place trees with brush- vs -my own script- 0 Answers

Terrain Tree Placing is Broken 0 Answers

Tree Creator Problems 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