• 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 Lordinarius · Sep 09, 2012 at 09:33 AM · terrainsize

How to set width and length of terrain via script ?

i couldn't find any solution

thanks

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
2
Best Answer

Answer by Eric5h5 · Sep 09, 2012 at 05:59 PM

Use TerrainData.size.

Comment
Add comment · Show 8 · 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 hkhurana82 · Apr 19, 2017 at 01:04 PM 0
Share

Thanks. Worked for me.

terrain.terrainData.size = new Vector3 (x , y, z);

avatar image $$anonymous$$ · Dec 08, 2018 at 04:20 PM 0
Share

Is not working for me

Assets/Samuel/RussianAirbaseV2/TerrainSize.cs(12,17): error CS1061: Type UnityEngine.GameObject' does not contain a definition for terrainData' and no extension method terrainData' of type UnityEngine.GameObject' could be found. Are you missing an assembly reference?

avatar image meikellp $$anonymous$$ · Feb 13, 2019 at 11:09 AM 0
Share

You need to call GetComponent<Terrain>().terrainData

avatar image Trond · Apr 06, 2019 at 09:31 PM 0
Share

No, this does not seem to set the size. I set the terrain data size to 128, but the actual terrain is 512 units in "physical size"...

avatar image Eric5h5 Trond · Apr 06, 2019 at 10:44 PM 0
Share

It does set the actual size. Either you misunderstood, or you're doing something wrong. As the docs say, "The total size in world units of the terrain."

avatar image Trond Eric5h5 · Apr 07, 2019 at 11:19 AM 1
Share

So it turns out that if you set the terrain size in the terrain datas object initialization, and then set the height data later, the size gets overwritten. So it is important to set the terrain size after the height data has been set.

Show more comments
avatar image
-1

Answer by Po0ka · Sep 09, 2012 at 05:43 PM

Via script i don't think it is possible, but you can click on "terrain" on the top left screen, click on "set resolution...", then you can edit the width, length, and height of a terrain. But via script, i have no idea. Ands since when you make a nice terrain and change the resolution, it goes flat and you must remake the map... So editing the size inside of the game qith a script seems improbable.

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 Eric5h5 · Sep 09, 2012 at 06:00 PM 0
Share

Setting the size of the terrain doesn't affect the resolution and doesn't clear the heightmap.

avatar image RKSandswept · Oct 08, 2013 at 10:05 PM 0
Share

You need to resize the terrain with the size, and it is typical to set the resolutions.

int res = (int)(ScenarioBlock.terrainWidth$$anonymous$$eters / ScenarioBlock.height$$anonymous$$ap$$anonymous$$etersPerPoint); TheDeadLinger.tdl.globalTerrain.terrainData.size = new Vector3(ScenarioBlock.terrainWidth$$anonymous$$eters, 1024.0f, ScenarioBlock.terrainWidth$$anonymous$$eters); TheDeadLinger.tdl.globalTerrain.terrainData.alphamapResolution = res; TheDeadLinger.tdl.globalTerrain.terrainData.heightmapResolution = res; TheDeadLinger.tdl.globalTerrain.terrainData.SetDetailResolution(res, 8);

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

16 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

Related Questions

Terrain Textures, bigger is better? 1 Answer

How do you get the Terrain Size (C#)? 2 Answers

best tile size for terrain? 2 Answers

Terrain Brush size to map size problem 0 Answers

How to extend tree size to more than 200? 0 Answers


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