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
2
Question by Statement · Apr 10, 2011 at 06:45 PM · meshrendering

Is it possible to render a mesh from code?

I am currently looking to render a bunch of meshes without having to instantiate several game objects for them. Is it possible to render a mesh from code, supplying material and transform matrix to it? I don't have PRO, so the GL functions are out of the question.

I spent some time in the docs but I was unable to find anything while searching. Apparently my google skills are lacking today as well.

What I'd love is some method like:

UnknownClass.Render(mesh, material, worldmatrix);
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
4
Best Answer

Answer by Statement · Apr 10, 2011 at 06:48 PM

Graphics.

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
1

Answer by FlyingOstriche · Oct 21, 2012 at 11:32 AM

Another way you can do it. (works in Indie)

you need to have a MeshFilter and MeshRenderer on object. << docs don't mention MeshRenderer.

Then set MeshFilter.mesh to the mesh.

Comment
Add comment · Show 3 · 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 MrVerdoux · Nov 23, 2012 at 09:48 AM 0
Share

I did it that way and it works. You just have to worry about giving vertex proper coordinates and then setting triangles, normals (if you need them), UV coordinates (if you need them)... It's kind of a shity work...

private Vector3[] newVertices;

private int[] newTriangles;

private $$anonymous$$esh my$$anonymous$$esh; //add this to the game object

private $$anonymous$$eshFilter my$$anonymous$$eshFilter; //add this to the game object

void Start {

my$$anonymous$$esh = new $$anonymous$$esh();

my$$anonymous$$eshFilter = ($$anonymous$$eshFilter) gameObject.GetComponent("$$anonymous$$eshFilter");

my$$anonymous$$eshFilter.mesh = my$$anonymous$$esh;

InitializeVertices(); //Do something with the vertex

my$$anonymous$$esh.vertices = newVertices;

InitializeTriangulation(); //Set the triangles index

my$$anonymous$$esh.triangles = newTriangles;

}

boring as hell...

avatar image The-Oddler · Nov 23, 2012 at 09:55 AM 0
Share

This is probably the best way. If the docs say Graphics is pro-only it's probably a bug that it works in indie, so might not work in future versions. It a bitch to do this though :P

avatar image jayhatmaker · May 19, 2013 at 10:05 AM 1
Share

It seems the document doesn't say "pro only" anymore?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Vertex Colours flickering blue 0 Answers

Rendering with cubes/planes/matrices 2 Answers

Problem in rendering meshes 2 Answers

Better model? Use Mesh clipping or add more vertices? 0 Answers

Script rendering Mesh to Image with transparent background 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