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
0
Question by joshrs926 · Jan 28 at 11:13 PM · editormesheditor-scriptinggenerationprocedural mesh

Why does Frame Selected toggle between position and bounds for procedural and imported meshes?

When I try to frame selected on a GameObject with a Mesh created from code or one imported as an fbx file from Blender, the camera will cycle between framing the mesh's origin, and framing the mesh's bounds. However if you select a default cube and repeatedly frame selected, the camera will first frame the cube's bounds and then not move anymore. The latter is the kind of behavior I want for my code created Mesh's and imported fbx files. I have included an example MonoBehaviour that you can attach to any GameObject to assign it a Mesh created in code that's just a quad. I am using Unity version 2020.3.16f1. So why doesn't the frame selected command behave the same for Meshes created in code and those imported as fbx files as for Unity's built in meshes like cubes and spheres and how do I get the behavior I want?

 using UnityEngine;
 
 [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
 public class TestMeshCreator : MonoBehaviour
 {
     public float meshScale = 1;
 
     public void AssignTestMesh()
     {
         var filter = GetComponent<MeshFilter>();
         var mesh = CreateMesh();
         filter.sharedMesh = mesh;
         mesh.RecalculateBounds();
 
         var rend = GetComponent<MeshRenderer>();
         rend.sharedMaterial = new Material(Shader.Find("Standard"));
     }
 
     Mesh CreateMesh()
     {
         Mesh mesh = new Mesh();
         mesh.name = "Test mesh";
         mesh.SetVertices(new Vector3[]
         {
             new Vector3(-.5f, 0, 0) * meshScale,
             new Vector3(+.5f, 0, 0) * meshScale,
             new Vector3(-.5f, 1, 0) * meshScale,
             new Vector3(+.5f, 1, 0) * meshScale,
         });
         mesh.SetIndices(new int[]
         {
             0, 2, 3,
             0, 3, 1
         }, 
         MeshTopology.Triangles, 
         0);
         mesh.RecalculateBounds();
         mesh.RecalculateNormals();
         return mesh;
     }
 
 #if UNITY_EDITOR
     [UnityEditor.CustomEditor(typeof(TestMeshCreator))]
     public class TestMeshCreator_Editor : UnityEditor.Editor
     {
         public override void OnInspectorGUI()
         {
             base.OnInspectorGUI();
             var t = target as TestMeshCreator;
             if (GUILayout.Button("Create Mesh"))
             {
                 t.AssignTestMesh();
             }
         }
     }
 #endif
 }
 

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by joshrs926 · Feb 05 at 09:12 PM

Can anyone help me with this issue?

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 joshrs926 · Feb 09 at 08:45 PM 0
Share

Any one have any ideas?

avatar image Eno-Khaon joshrs926 · Feb 09 at 09:25 PM 0
Share

I don't have a conclusive answer to this, but there may be slightly different behavior depending on whether your current Pivot Mode for the Editor Manipulation Handles is set to "Center" or "Origin" modes.

I point this out, for example, in case the pivot point is far from the center of the bounds of your mesh. It might not be an applicable factor (for many reasons), but it could be worth looking at in case there are differences in behavior when fra$$anonymous$$g your selection based on Pivot Mode.

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

196 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 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

how to get 2 vertices from mesh edge? 1 Answer

Mesh visible in editor but not build 1 Answer

Editor Script Handles.Label problem. Labels don't move with gameobject 1 Answer

Prevent seams on a generated mesh with split edges. 0 Answers

Creating a mesh and assigning a material during edit time. 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