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
0
Question by cdrandin · Jan 15, 2013 at 10:06 PM · meshassetdatabase

Trying to make my own plane using only 2 triangles?

So unity provides gameobject creation of a plane which contains a lot of triangles in which Unity calculates which is really unneeded for a simple plane. I was following a tutorial on how to do this, but I am getting an error.

Optimized Plane script:

 #pragma strict
 
 class OptPlane extends Editor{
     @MenuItem("GameObject/Create Other/Opt Plane")
     
     static function Init (){
         var customPlane : GameObject = new GameObject("Optimized Plane");
         var meshFilter : MeshFilter  = customPlane.AddComponent(MeshFilter);
         customPlane.AddComponent(MeshRenderer);
         
         var destination : String = "Asset/Model/OptimizedPlane.asset";
         var mesh : Mesh = AssetDatabase.LoadAssetAtPath(destination, Mesh);
         
         if(! mesh){
             mesh      = Mesh();
             mesh.name = 'Optimized Plane';
             
             var vertices : Vector3[]  = [Vector3(-1,0,1), Vector3(1,0,1), Vector3(1,0,-1), Vector3(-1,0,-1)];
             var uv       : Vector2[]  = [Vector2(-1,1), Vector2(1,1), Vector2(1,-1), Vector2(-1,-1)];
             var tangents : Vector4[]  = [Vector4(-1,0,1,1), Vector4(1,0,1,1), Vector4(1,0,-1,1), Vector4(-1,0,-1,1)];
             var triangles: int[]      = [0,1,3,3,1,2];
             
             mesh.vertices  = vertices;
             mesh.uv        = uv;
             mesh.tangents  = tangents;
             mesh.triangles = triangles;
             
             mesh.RecalculateNormals();
             mesh.RecalculateBounds();
             mesh.Optimize();
                         AssetDatabase.CreateAsset(mesh, destination);
             AssetDatabase.SaveAssets();
         }
         
         meshFilter.mesh = mesh;
         Selection.activeObject = customPlane;
     }
 
 }

Warning: UnityException: Creating asset at path Asset/Model/OptimizedPlane.asset failed. OptPlane.Init () (at Assets/Editor/OptPlane.js:32)

I understand that it can't create it to this location I sent it, but from the tutorial he did nothing special besides create a "Model" folder and it just worked for him. Also, what is this .asset extension, I am just guessing it is what Unity uses to create objects in the scene or something.

Comment
Add comment · Show 3
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 cdrandin · Jan 15, 2013 at 10:07 PM 0
Share

Here is the link for reference. http://www.youtube.com/watch?feature=player_detailpage&v=ojEAHx_vY3U#t=1952s

avatar image Fattie · Jan 16, 2013 at 07:57 AM 0
Share

@cdrandin just for the record. If you are trying to make essentially "2D sprites"

"2DToolkit" from the asset store is hugely popular. it would be more or less impossible or years more work to do 2D sprites in unity without it.

it utterly takes care of resizing quads as you discuss, animations, colliders, sprite atlases etc

Grab 2DTooljit and all the similar packages, and decide which one you like. Hope it helps!

avatar image cdrandin · Jan 16, 2013 at 09:25 AM 0
Share

Thanks, I will check it out.

1 Reply

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

Answer by DaveA · Jan 15, 2013 at 10:34 PM

Try: Assets/Model/OptimizedPlane.asset

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 cdrandin · Jan 15, 2013 at 10:50 PM 0
Share

Dame, that 1 letter has causes me so much grief. Thanks

avatar image Fattie · Jan 16, 2013 at 07:55 AM 0
Share

who knew ?!

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

10 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

What is the "correct" what to make a procedural mesh script 0 Answers

Triangle Mesh Problem 2 Answers

Modifying vertices values in a mesh 1 Answer

Determining which Asset is connected to a GameObject. 3 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