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 Random username · Dec 16, 2012 at 10:12 AM · outline

Drawing an outline around object

Hey, I'm using an orthographic camera from a top down view and when an object is selected I would like to draw an outline around it that scales to the size of the objects collider. This is probably simple enough to do with a mesh, but the problem I see happening is the width of the outline changing as I scale the mesh, which I don't want. What's the best way to get around this?

EDIT: By outline I mean just a rectangular outline with the width and length of the objects bounding box collider

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 Fattie · Dec 16, 2012 at 10:14 AM 0
Share

what are the objects in the game?

are the objects cats, spaceships, or square images? or rectangular?

secondly what "are" the objects? are they 3D models, 2D sprites, colliders, or what?

avatar image Random username · Dec 16, 2012 at 10:55 AM 0
Share

Sorry for the lack of information, the objects can be a range of things, turrets, fences etc. Each will have a 'bounds' collider which will be used for making sure that these objects are not placed intersecting others. The outline should be drawn with the width and length of this bounding box collider. EDIT: By outline I just mean a rectangle around it, sorry I didn't realise I hadn't said that in my first post.

1 Reply

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

Answer by Fattie · Dec 16, 2012 at 11:58 AM

OK thanks for clarifying that you want to draw four straight lines, as seen from the camera, in the shape of a box, around some objects.

There's basically two ways to draw lines un Unity.

You can use the LineRenderer which is free with Unity. Simply read the doco, it is very easy to use.

Or you can grab Vectrosity on the asset store for two dollars, which pretty much everyone uses for drawing lines, glowing lines, and the like.

There is a third remarkably easy way:

  1. right now in unity in the editor, just "make" a "line". So, make it exactly 10 cm wide, and 1 meter long. Very simply make a "plane" using a silly unity primitive, and stretch it so it is as I describe.

  2. it might be easuer for you to make a horizontal one of those, and also a vertical one

  3. name those objects say MeterLineH and MeterLineV. (note that this will now have a scale of "1" both ways)

  4. carefully make a little system where you supply a length (say "2.3 m"). the system takes your original MeterLineV and simply scales it, in this case simply to 2.3 on the vertical length. Do the same thing for horizontal

  5. note that you can color the originals (from point 1) any way you want, etc

  6. As you can see, you can now, with one line of code, make horizontal or vertical lines, any length you want, and always a fixed 10cm in width. Voila.

  7. just carefully write a routine that makes a BOX from four of those

So really that's how you do it. Note that, FWIW, there's no reason not to use a "cube" in step 1 (stretch it out). Or you could "properly"

Let me finally say - did uou look at Unity's (annoying and crappy) GUI system?

Note that it has stupid features like "box" and so on ...

http://docs.unity3d.com/Documentation/ScriptReference/GUI.html

Be aware it will take you 10x, or 40x longer to use their "GUI" system, than simply do the 7 steps I mention above!

Finally !!!

Funnily enough I had exactly this problem once. Let me dfraw your attention to a great little product on the Asset Store (it's only five bucks!) called "Dynamic Circles" - everyone should have it, it;s so good

notice in this question (similar to yours here), I came to that conclusion

http://answers.unity3d.com/questions/238526/easiest-way-to-make-a-kind-of-glowing-indicator-ar.html

Hope all of this helps in some way! So your solutions are

  • LineRenderer of Unity, a bit clunky for this

  • learn Vectrosity, the go to solution for glowing lines etc

  • surprisingly, just make essentially stretched planes, to make tidy squared-off lines

  • note the natty "Dynamic Circles" asset which is neat (since it's only a few bucks, just grab it without hesitation as it's interesting)

Hope this helps! Cheers!

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 Random username · Dec 16, 2012 at 12:31 PM 0
Share

Thanks for the great info Fattie, that third method looks pretty good. Also for the link to dynamic circles, probably going to have to pick that up, it looks awesome!

"Let me finally say - did uou look at Unity's (annoying and crappy) GUI system?" Yes I did. It was annoying and crappy. Pretty much just waiting for the new system to come out before I do much work on my game's gui (wish I could find a release date somewhere lol). But I should at least be able to get this working for now so thank you very much!

avatar image Fattie · Dec 16, 2012 at 03:03 PM 0
Share

LOL on the gui !

really i think it's better just to make one's own, I use 2DToolkit everywhere, it's pretty essential in Unity

well cheers

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

12 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

Related Questions

Combining two Outline Shaders 1 Answer

How to make a outline shader with custom attributes 0 Answers

Using a texture map to determine the colors of a toon outline? 0 Answers

Mixed Standard and outline shader, outline not showing at some distances 0 Answers

It there Outline for TileMap tile? 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