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
1
Question by 3dDude · Jul 13, 2010 at 03:06 PM · linerendererremove

LineRenderer GetPosition? not there.

hi i asked a question a few months ago here and someone said to use the getPosition and setPosition. but i looked in the lineRenderer class in the scripting reference and i could not find GetPosition.

is it possible that it was removed?

thanks.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by Mike 3 · Jul 13, 2010 at 07:23 PM

The reply you quoted said that it wasn't possible with the built in LineRenderer, and instead said to extend the original class

Sounds like a good plan to me - Something like this should do it (in c# - my js is too rusty for inheritance):

using System; using UnityEngine;

public class AccessibleLineRenderer : LineRenderer { private Vector3[] vertices = new Vector3[0]{};

 new public void SetPosition(int index, Vector3 position)
 {
     vertices[index] = position;
     base.SetPosition(index, position);
 }

 new public void SetVertexCount(int count)
 {
     Array.Resize(ref vertices, count);
     base.SetVertexCount(count);
 }

 public Vector3 GetPosition(int index)
 {
     return vertices[index];
 }

}

Comment
Add comment · Show 17 · 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 3dDude · Jul 13, 2010 at 07:52 PM 0
Share

it look good but i'm a JS user :(

avatar image Mike 3 · Jul 13, 2010 at 07:53 PM 0
Share

I'm not sure js has the new syntax, so i'll write a js version without it

avatar image Mike 3 · Jul 13, 2010 at 07:58 PM 0
Share

You'll need to use different function names for js, not sure you can shadow the functions properly without warnings. Alternatively, you could slap the c# version into Plugins or Standard Assets and it should work the same from js ;)

avatar image 3dDude · Jul 13, 2010 at 08:35 PM 0
Share

i got a console filled with errors :(

avatar image nicloay · Sep 10, 2012 at 04:16 PM 1
Share

Cant use inheritance, it show me this error `CustomLineRenderer': cannot derive from sealed type `UnityEngine.LineRenderer'

Show more comments
avatar image
1

Answer by alisator · Nov 20, 2012 at 09:07 AM

Hey, maybe I ll get the answer here...

 private void axes()
 {
     Debug.Log ("start line");
     Color c1 = Color.yellow;
     Color c2 = Color.red;
         int lengthOfLineRenderer = 20;
         LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
         lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
         lineRenderer.SetColors(c1, c2);
         lineRenderer.SetWidth(0.01f, 0.9f);
         lineRenderer.SetVertexCount(lengthOfLineRenderer);
     for(int i = 0; i < lengthOfLineRenderer; i++)
         {
         Vector3 pos = new Vector3(i, 0.0f, 0f);
               Vector3 pos2 = new                  Vector3(i,i,0.0f);
                //lineRenderer.SetPosition(0,pos);
         lineRenderer.SetPosition(10,pos2);
     }
 }

I tried different indexes, and hey? The line was rendered in different way - I just wanted have axis x and axis y, but I dot get, how the indexes working, and on unity website i found nothing... Do you know meaning of those indexes? Thx a lot!

Comment
Add comment · Show 1 · 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 B3ukenn00tje · Nov 12, 2015 at 08:37 AM 0
Share

the linerenderer.setposition() want 2 argument, first a integer as the index and then a vector3 as position. the index here is which point in line the position get set to, so if the index is 0, then it will be the first point of the line. and in your code index being 20 the last. the simples way of doing this is to use " lineRenderer.SetPosition(i,pos); " if you put this in a for loop which adds to i every time it loops through and the position had i in it then you would get a line. if you don't change " pos " in the loop you would just set a line which stays at the same point, which isn't what you want.

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Help With Add and Remove on a loop 2 Answers

Line Renderer Not Displaying in 2D Game Window 0 Answers

Remove all clips from animation by script 2 Answers

Laser Beam in Unity 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