Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Darholm · Mar 23, 2016 at 09:05 AM · c#scripting problemtree

How to dynamically instanciante SpeedTree assets from script?

Hello,

I am trying to figure out how I can create and put in my scene SpeedTree assets using a C# script. So I have downloaded the Free_SpeedTrees package and drag drop one of them in my scene to see what results in the Hierarchy panel. It appears that a SpeedTree asset is based on : -object with LOD component |_billboard |_LOD n |_LOD n+1 |_Collision object n |_Collison object n+1

Each LOD has a MeshFilter that loads the .spm file it needs.

I looked into the documentation (both Manual and Scripting API). I found no class for SpeedTree, except the SpeedTreeImporter but it seems that this class only customize import settings.

Then I looked into LODComponent and LOD, but the only example uses Primitives.

I also went through the MeshFilter class and its Mesh attribute, which appears in the Editor as a filepath but is instead a Mesh object in the API. Unfortunatly, the Mesh object has no method for loading a 3D file and building itself from the file.

I really have no clue on where to start, which class is needed. Don't even know if it is possible to dynamically create SpeedTree from script, as both the Forums and the Answers area are weak on this subject.

So any help would be greately 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 Ali-hatem · Mar 23, 2016 at 12:20 PM

  1. you can instantiate any thing from script just make the object a Prefabs by drag & drop from hierarchy to Asset folder & delete it from hierarchy.

  2. then create an empty game object in hierarchy & attach a script to it .

  3. open the script :

    public class Example : MonoBehaviour{ public GameObject obj; void Start(){ Instantiate (obj,transform.position,transform.rotation); } }

now back to unity click the object this script attached to in the script component you will see an empte field called obj . drag the Prefab from Asset folder to this field & hit play you will see a game object created at the same position of the game object position you putted in the scene for more info see the doc unity doc

& unity tutorial

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 Darholm · Mar 31, 2016 at 08:18 AM

Hello,

Thanks for your answer but it doesn't help. I know about the solution you gave as I am already doing this kind of stuff in others scripts. But here I have to process differently : the idea is to dynamically create speedtrees in my scene without asking the user to do all these actions. Trees will be listed in an XML file with their transform datas and asset file. My problem is to create the speedtrees, XML handling is trivial stuff.

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

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

Related Questions

Tree chopping 0 Answers

Problem with Score/Highscore script 0 Answers

button.onClick.AddListener in for loop 2 Answers

How to rotate RigidBodyFPSController (C#) 1 Answer

.rotation doesn't seem to work, can't shoot projectile at mouse coordinates 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