• 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
Question by theBuilder10000 · Aug 12, 2022 at 08:00 AM · meshruntimeproceduralmesh colliderexternal-tools

Changing shape of Poly Mesh in ProBuilder at runtime.

I'm creating a game utilizing OSM date for geographic subdivisions. A lot of the game hinges on creating meshes that follow the preset borders, and I want to stream line this process by creating the shapes at runtime using the Vector coordinates from the OSM JSON files. ProBuilder gives me the shapes I need (Poly Shapes), but they can only be made using the pro builder editor using point and click functionality. I was able to transfer the appropriate points into the Poly Shape component at runtime, but the mesh does not update to reflect the new points. Refresh() doesnt work, and CreateShapeFromPolygon() doesn't work. Any help with this issue, or some suggestion of a new method of achieving this , would be greatly appreciated.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.ProBuilder;
 using UnityEngine.ProBuilder.MeshOperations;
 
 
 public class OSMCountyScript : MonoBehaviour
 {
     public PolygonCollider2D boundary;
     public string name;
     public Vector2 center;
     public Vector2[] boundaryPoints;
     public Vector3[] boundaryPoints3D;
     public ProBuilderMesh countyMesh;
     public PolyShape countyPoly;
     // Start is called before the first frame update
     void Start()
     {
         countyMesh = gameObject.AddComponent<ProBuilderMesh>();
         for (int i = 0; i < boundaryPoints.Length - 1; i++)
         {
             boundaryPoints3D[i].x = boundaryPoints[i].x;
             boundaryPoints3D[i].z = boundaryPoints[i].y;
         }
         List<Vector3> boundaryPointsList = new List<Vector3>();
         boundaryPointsList.AddRange(boundaryPoints3D);
         countyPoly.m_Points = boundaryPointsList;
         countyPoly.SetControlPoints(boundaryPointsList);
     }
 }

The Poly Shape and Mesh Component before runtime after making a basic Poly Shape using the built ProBuilder editor tools.

alt text

The Poly Shape component after runtime, with all 44 custom positions integrated into the Poly Shape script.

alt text

probuilder-2.png (75.2 kB)
probuilder-3.png (85.3 kB)
Comment

People who like this

0 Show 0
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

166 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

Related Questions

Conforming a mesh path to arbitrary surface - runtime 1 Answer

Runtime import of Collada files 3 Answers

Mesh creation during runtime 0 Answers

Deleting one triangle out of mesh? Cut hole in mesh in runtime? 4 Answers

Check if a mesh has UV map at runtime 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