• 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
1
Question by IBDelta · Jan 12, 2011 at 09:25 AM · textureinstantiateterrainprocedural

Random terrain generation at runtime

I have been trying different ways to get this code for a couple of days now. No matter what I try it's been throwing errors left right and centre, usually about splat-maps being null. The terrain is generated from an instantiated prefab with this script attached. The inspector is set with all of the pieces in place but it still doesn't work. Can someone please tell me where I'm going wrong.

var Tex1Txt : TextAsset; var Tex2Txt : TextAsset; var Tex3Txt : TextAsset; var Tex4Txt : TextAsset;

var Tex1= new Texture2D (1024,1024); var Tex2= new Texture2D (1024,1024); var Tex3= new Texture2D (1024,1024); var Tex4= new Texture2D (1024,1024); Tex1.LoadImage(Tex1Txt.bytes); Tex2.LoadImage(Tex2Txt.bytes); Tex3.LoadImage(Tex3Txt.bytes); Tex4.LoadImage(Tex4Txt.bytes);

var TerrData : GameObject; TerrData = GameObject.Find("TrainTerrainPrefab(Clone)"); TerrData.GetComponent("TerrainToolkit").FractalGenerator(0.25, 0.25);

var slopeStops : float[] = [20.0, 50.0]; var heightStops : float[] = [0.2, 0.4, 0.6, 0.8]; var textures : Texture2D[] = [Tex1, Tex2, Tex3, Tex4];

function Awake () {
TerrData = GameObject.Find("TrainTerrainPrefab(Clone)"); TerrData.GetComponent("TerrainToolkit").FractalGenerator(0.25, 0.25); TerrData.GetComponent("TerrainToolkit").TextureTerrain(slopeStops, heightStops, textures); }

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 DaveA · Jan 13, 2011 at 10:44 PM

Just a wild guess: what if you moved the initialization of Tex1-4 into the start of the Awake function? 'textures' too. And you can remvoe dht TerrData inits from the above section, leave it in Awake only

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

Answer by IBDelta · Jan 14, 2011 at 05:33 AM

Thank you, a wild guess is still a good help :-)

I managed to get the textures loaded by using Resources.Load and putting them into a resources folder. The API example at the 6x0 website gives me the following error. link text

Error: heightStops contains an incorrect number of values.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Pixelated Texture Edges on Terrain 0 Answers

Adding multiple textures to a procedurally generated terrain mesh? 0 Answers

Procedural Texturing on Multiple Terrain Mesh 1 Answer

Terrain Toolkit and Texturing via Code HELP! 1 Answer

Instantiating too much at Start? Terrain Objects. 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