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 Pthorndycraft · Oct 14, 2014 at 02:03 PM · meshline

How to draw a line around multiple/child objects?

Hi all, I hope someone can give me a point in the right direction with the following as I have had trouble finding any examples/techniques:

I have a parent object which contains a number of child objects (Tiles) which can be placed in any shape but they are all still touching. I need to draw a line around the edge of all the child items together. For example, if the tiles make an L shape, the line would be drawn around making an L rather than around each tile separately.

I've had a couple of thoughts to solve this:

  1. Get the vertices of all child items, remove the inner items, keeping the edge vertices and then drawing a line between. No idea how to find the edge items though and getting them in the right order (clockwise) may be tricky.

  2. Generating a mesh from the child object mesh's and then applying a sillouette shader?? Not sure how to do this though but it feels the right way to go. I have the shader but not sure how to get meshes from sprite renderer components.

  3. I saw a plugin that draws lines around groups of objects but I can't seem to find it again now.

Has anyone done this before??

I could simply fill all the tiles with a colour to give a different feel but its not really what I am going for.

Later down the line I would also like to make a polygon collider using the same shape.

Thanks in advance!

Peter

Comment
Add comment · Show 2
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 _dns_ · Oct 14, 2014 at 02:30 PM 0
Share

Hi, are your tiles all of the same size ? If so, you could use a logic representation of the grid composed by them: imagine a table[,] containing booleans representing the presence or absence of a tile at a tile position. Then, you can easily detect edges by comparing table elements (if this tile is "on" and tile on the right is "off", then there is a line there).

Then, you could use $$anonymous$$eshTopology http://docs.unity3d.com/ScriptReference/$$anonymous$$eshTopology.html to create a mesh composed of lines (if lines are what you want: I guess those lines are 3D lines but always rendered 1 pixel thick, like Debug.DrawLine() )

avatar image robertbu · Oct 14, 2014 at 02:33 PM 0
Share

If you want to tackle #1, I outline a solution in this answer. It would be a bit of work:

http://answers.unity3d.com/questions/804696/combining-shapeslist.html

Note for squares, the point in rect and intersection of segments are much easier to calculate than in the general case.

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Creating a polygon from a set of paired Vector3s 1 Answer

Mesh line renderer - line segments camera align 1 Answer

Is direct MeshRenderer vertex mutation (or dynamic Mesh building) possible? 2 Answers

Weird Line Between Meshes 1 Answer

Identify if two vertices are connected 0 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