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 madmike6537 · Oct 08, 2013 at 01:21 AM · linerenderer

Trying to draw a box with Line Renderer, trouble

EDIT: So it seems to work if I just instantiate one gameobject and not the 4 to make up the four sections of the line. The hell? Can you only have one line renderer in the scene? I DO have them as seperate gameObjects, each with their own line renderer.. Hmm.

So I am trying to draw a box on the screen with line renderer. was able to draw a single line no problem, but now I cant get it to work. Not sure what happened..

I have a prefab with a line renderer component, I have tried changing around the properties. When I drag it into the scene, its fine. See picture:

alt text But when I instantiate the prefab from my script, it shows up blank!

code:

 GameObject top = Instantiate(linePrefab, new Vector3(curMousePos.x, (curMousePos.y - 1), curMousePos.z), Quaternion.identity) as GameObject;

Picture of the blank instantiation:

alt text

I am at a loss, I cant figure out why it is blank when I instantiate via code. Cant find anything in the manual that describes any special action I need to take with instantiating line renderers. Worse, I had it working fine as a single line, now when trying to instantiate multiple lines it doesnt seem to work - arg!

cap1.jpg (147.5 kB)
cap2.jpg (110.6 kB)
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 TrickyHandz · Oct 08, 2013 at 03:36 AM 0
Share

How many positions do you have in the line renderer's Positions array. If there aren't any, then the line renderer won't draw a line.

avatar image madmike6537 · Oct 08, 2013 at 04:07 AM 0
Share

There are two in each, but u might have them at the same point at the beginning I will check that.

avatar image Fattie · Oct 08, 2013 at 09:44 AM 0
Share

Forget it, you need Vectrosity (asset store)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by plasticYoda · Oct 08, 2013 at 04:30 AM

I just tried what you did, and it worked fine for me. Created an empty game object and added a line renderer to it, prefab'd it, deleted the original and brought back the prefab and it worked as expected.

Couple of things:

The points in the Positions array are in world space and ignore the parent's transform by default, so even if the object is where you want it, it's possible the lines are not.

When you chain more than one line on a given line-renderer it ends up getting pinched at various points along it, depending on the angle between consecutive segments. This is probably not what you want.

You can only have one line-renderer per gameobject, so to make a square, you want four gameobjects with one line per object.

Comment
Add comment · 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

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

18 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

Related Questions

Line renderer rotation and alignment 1 Answer

Generate a mesh around a LineRenderer 2 Answers

Filling area under positions with Mesh 0 Answers

LineRenderer renders the wrong color 3 Answers

Unity C#: Line renderer from Gameobject (3D) to Canvas (Screen Space - Camera) 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