PowenKo, Unity3D Tutorial 121, draw line

October 27, 2011   ·   0 Comments

4 solution.

1. LineRenderer

http://unity3d.com/support/documentation/Components/class-LineRenderer.html

2.DrawLine

http://unity3d.com/support/documentation/ScriptReference/Gizmos.DrawLine.html

var target : Transform;
function OnDrawGizmosSelected () {
    if(target != null) {
        // Draws a blue line from this transform to the target
        Gizmos.color = Color.blue;
        Gizmos.DrawLine (transform.position, target.position);
    }
}

3.http://unity3d.com/support/documentation/ScriptReference/Debug.DrawLine.html

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void Update() {
        Debug.DrawLine(Vector3.zero, new Vector3(1, 0, 0), Color.red);
    }
}



using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void OnCollisionEnter(Collision collision) {
        foreach (ContactPoint contact in collision.contacts) {
            Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2);
        }
    }
}

4. Draw on GUI

http://forum.unity3d.com/threads/17066-How-to-draw-a-GUI-2D-quot-line-quot

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon