Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
1
Question by Thet Naing Swe · Oct 07, 2010 at 02:22 AM · guitexturecreatequad

how can I create a quad from script?

How can I create a quad from script with a specific texture attached on it as it will mainly used for rendering 2D stuffs with orthographic camera instead of using GUITexture which is really expensive if there are loads of GUITexture objects on iPhone..

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Dreamora · Oct 07, 2010 at 02:37 AM

You would do so through the Mesh class

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 Thet Naing Swe · Oct 07, 2010 at 02:45 AM 0
Share

yes.. it can be done through mesh class although it's quite complex lolz.. It's better if we can use the other 3d $$anonymous$$odelling software to draw quads and using texture atlas...

avatar image Jesse Anders · Oct 07, 2010 at 03:27 AM 0
Share

It's not complex. But, creating a simple 'quad' model in a modeling program and just using that would be a viable option as well.

avatar image
3

Answer by luci1B · Jun 03, 2014 at 08:23 AM

You can do it that way :

 var go = GameObject.CreatePrimitive(PrimitiveType.Quad);
 go.renderer.material.mainTexture = texture;
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 Tokars · May 15, 2020 at 08:51 AM

Today I asked the same question. Here how create a custom quad:

 public class CustomQuad : MonoBehaviour
     {
         private Mesh _mesh;
         private float width = 2f;
         private float height = 2f;
         void Start()
         {
             var mf = GetComponent<MeshFilter>();
             _mesh = new Mesh();
             mf.mesh = _mesh;
     
             var vertices = new Vector3[4];
     
             vertices[0] = new Vector3(0, 0, 0);
             vertices[1] = new Vector3(width, 0, 0);
             vertices[2] = new Vector3(0, height, 0);
             vertices[3] = new Vector3(width, height, 0);
     
             _mesh.vertices = vertices;
     
             var tri = new int[6];
 
             tri[0] = 0;
             tri[1] = 2;
             tri[2] = 1;
     
             tri[3] = 2;
             tri[4] = 3;
             tri[5] = 1;
     
             _mesh.triangles = tri;
     
             var normals = new Vector3[4];
     
             normals[0] = -Vector3.forward;
             normals[1] = -Vector3.forward;
             normals[2] = -Vector3.forward;
             normals[3] = -Vector3.forward;
     
             _mesh.normals = normals;
     
             var uv = new Vector2[4];
 
             uv[0] = new Vector2(0, 0);
             uv[1] = new Vector2(1, 0);
             uv[2] = new Vector2(0, 1);
             uv[3] = new Vector2(1, 1);
     
             _mesh.uv = uv;
         }
 
         private void OnDrawGizmos()
         {
             Gizmos.color = Color.cyan;
             Gizmos.DrawWireMesh(_mesh, Vector3.zero);
         }
     }


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

2 People are following this question.

avatar image avatar image

Related Questions

Create Legacy Ellipsoid Emitter from script 0 Answers

Import and Material Question 2 Answers

How to change pixel inset of GUITexture? 2 Answers

I need help with a companion!!! 2 Answers

how do you create an ios asset bundle from the editor 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