本文整理汇总了C#中UnityEngine.LineRenderer.SetColors方法的典型用法代码示例。如果您正苦于以下问题:C# LineRenderer.SetColors方法的具体用法?C# LineRenderer.SetColors怎么用?C# LineRenderer.SetColors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.LineRenderer
的用法示例。
在下文中一共展示了LineRenderer.SetColors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
// Link to LeanTouch events
LeanTouch.OnFingerDown += OnFingerDown;
LeanTouch.OnFingerUp += OnFingerUp;
LeanTouch.OnSoloDrag += OnSoloDrag;
LeanTouch.OnMultiDrag += OnMultiDrag;
currFinger = null;
// Initialize LineRenderer
lineGameObject = new GameObject("SlashLine");
lineGameObject.AddComponent<LineRenderer>();
lineRenderer = lineGameObject.GetComponent<LineRenderer>();
lineRenderer.material = new Material(Shader.Find("Mobile/Particles/Additive"));
lineRenderer.SetColors(c0, c1);
lineRenderer.SetWidth(0.1f, 0f);
lineRenderer.SetVertexCount(0);
// Initialize other variables
i = 0;
slashing = false;
soloDragging = false;
currSoloDragDelta = Vector2.zero;
// Init GM ref
GM = GameObject.Find("GameManager").GetComponent<GameManager>();
}
示例2: EraseAlpha
IEnumerator EraseAlpha(LineRenderer target, float time)
{
Renderer renderer = target.GetComponent<Renderer>();
float originalStartAlpha = 1f;
float destinationStartAlpha = 0f;
float originalEndAlpha = 1f;
float destinationEndAlpha = 0f;
float currentTime = 0.0f;
Color startColor = Color.black;
Color endColor = Color.black;
do
{
startColor.a = Mathf.Lerp(originalStartAlpha, destinationStartAlpha, currentTime / time);
endColor.a = Mathf.Lerp(originalEndAlpha, destinationEndAlpha, currentTime / time);
target.SetColors(startColor, endColor);
currentTime += Time.deltaTime;
yield return null;
}
while (currentTime <= time);
// destroy self after fading away
Destroy(gameObject);
}
示例3: Start
// Use this for initialization
void Start()
{
line_renderer = (LineRenderer)this.gameObject.GetComponent<LineRenderer>();
line_renderer.SetWidth(1f, 3f);
line_renderer.SetColors(Color.red, Color.green);
line_renderer.SetVertexCount(2);
}
示例4: Start
//Variables End___________________________________________________________
// Use this for initialization
void Start()
{
if(networkView.isMine == true)
{
//Store a reference to these objects since we will need to reference
//them frequently.
myTransform = transform.parent;
cameraHeadTransform = myTransform.FindChild("CameraHead");
resourceScript = myTransform.GetComponent<PlayerResource>();
changeScript = myTransform.GetComponent<ChangeWeapon>();
//Attaching a LineRenderer component which will give a visual
//effect for the block eraser. Only the player will be able to see it.
lineRenderer = gameObject.AddComponent<LineRenderer>();
lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
lineRenderer.SetColors(c1, c2);
lineRenderer.SetWidth(0.04f, 0.01f);
lineRenderer.SetVertexCount(2); //Start and end position.
}
else
{
enabled = false;
}
}
示例5: Start
void Start () {
lineRenderer = gameObject.AddComponent<LineRenderer>();
lineRenderer.SetColors(Color.red, Color.red);
lineRenderer.material = mat;
lineRenderer.SetWidth(0.1f, 0.1f);
lineRenderer.SetVertexCount(2);
}
示例6: Awake
// Use this for initialization
void Awake()
{
visualLine = GetComponent<LineRenderer> ();
player = GameObject.FindGameObjectWithTag ("Player").transform;
visualLine.SetColors (Color.red, Color.red);
visualLine.SetWidth (0.01f, 0.01f);
}
示例7: Start
void Start()
{
highlight_box = (GameObject) Instantiate(highlight_prefab, new Vector3(1000f, 1000f, 1000f), Quaternion.identity);
movement_line = (LineRenderer) ((GameObject) Instantiate(new GameObject("movement_line"), new Vector3(0f, 0f, 0f), Quaternion.identity)).AddComponent<LineRenderer>();
movement_line.SetColors(Color.cyan, Color.cyan);
movement_line.SetWidth(.2f, .2f);
movement_line.SetVertexCount(3);
highlight_box.GetComponent<Renderer>().enabled = false;
movement_line.enabled = false;
for (int y = 0; y < map_size; y++)
{
List<Tile> row = new List<Tile>();
for (int x = 0; x < map_size; x++)
{
Tile tile = ((GameObject)Instantiate(tile_prefab, new Vector3(x - Mathf.Floor(map_size / 2), 0f, y - Mathf.Floor(map_size / 2)), Quaternion.identity)).GetComponent<Tile>();
tile.grid_position = new Vector2(x, y);
row.Add(tile);
}
map.Add(row);
}
player = ((GameObject)Instantiate(player_prefab, new Vector3(7f, 1.2f, 7f), Quaternion.identity)).GetComponent<Player>();
player.gameObject.tag = "Player";
other_player = ((GameObject)Instantiate(player_prefab, new Vector3(7f, 1.2f, -7f), Quaternion.identity)).GetComponent<Player>();
other_player.gameObject.AddComponent<QuestGiver>();
other_player.gameObject.tag = "QuestGiver";
players.Add(player);
players.Add(other_player);
current_player = players[current_player_index];
destination = player.transform.position;
current_player.start_turn();
}
示例8: Start
// Use this for initialization
void Start () {
lRend = new GameObject().AddComponent<LineRenderer>() as LineRenderer;
lRend.name = "Travel Path";
lRend.gameObject.transform.parent = this.transform;
dRend = new GameObject().AddComponent<LineRenderer>() as LineRenderer;
dRend.name = "Destination Outline";
dRend.gameObject.transform.parent = this.transform;
Color c = new Color (0.8f,0.1f,0.1f,0.5f);
dRend.material = render;
dRend.SetColors(c,c);
lRend.material = render;
lRend.SetColors(c,c);
timeToDestination = Vector3.Distance(origin.transform.position,destination.transform.position) / 5;
transform.position = Vector3.MoveTowards(origin.transform.position,
destination.transform.position,
(origin.transform.localScale.x/2) + (transform.localScale.z/2));
Vector3 lookPos = destination.transform.position;
lookPos = lookPos - transform.position;
float angle = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
timeToDestination = Vector3.Distance(destination.transform.position, origin.transform.position) / 2f;
speed = Vector3.Distance (origin.transform.position, destination.transform.position) / timeToDestination;
if (SceneManager.GetActiveScene().buildIndex == GameManager.SystemLevel) {
transform.localScale = new Vector3(5,5,5);
}
}
示例9: Awake
void Awake()
{
// Set up line renderer.
child = new GameObject("Bird Renderer");
child.transform.SetParent(transform);
lineRenderer = child.AddComponent<LineRenderer>();
lineRenderer.sharedMaterial = Resources.Load("Materials/Unlit") as Material;
lineRenderer.useWorldSpace = false;
lineRenderer.SetColors(color, color);
lineRenderer.SetWidth(lineWidth, lineWidth);
// Set up ship and use line renderer.
drawPoints = new List<Vector3>();
foreach (Vector2 point in shipPoints)
{
Vector3 pos = new Vector3(point.x, point.y, 0);
drawPoints.Add(pos);
}
SetPoints(drawPoints);
// Setup the polygon collider.
//polyCollider = child.AddComponent<PolygonCollider2D>();
//polyCollider.points = shipPoints;
// Set up the circle collider.
//circleCollider = child.AddComponent<CircleCollider2D>();
//circleCollider.isTrigger = true;
}
示例10: OnMouseDown
void OnMouseDown()
{
float sizeValue = (2.0f * Mathf.PI) / theta_scale;
size = (int)sizeValue;
size++;
lineRenderer = gameObject.AddComponent<LineRenderer>();
//lineRenderer.material = new Material(Shader.Find("Materials/Menu"));
lineRenderer.SetWidth(0.02f, 0.02f); //thickness of line
lineRenderer.SetVertexCount(size);
Vector3 pos;
float theta = 0f;
for (int i = 0; i < size; i++)
{
theta += (2.0f * Mathf.PI * theta_scale);
float x = radius * Mathf.Cos(theta);
float y = radius * Mathf.Sin(theta);
x += canvasSheet.transform.position.x;
y += canvasSheet.transform.position.y;
float z = canvasSheet.transform.position.z - 0.1f;
pos = new Vector3(x, y, z);
lineRenderer.SetColors(c1, c1);
lineRenderer.SetPosition(i, pos);
}
}
示例11: Start
void Start () {
lineRenderer = GetComponent<LineRenderer>();
lineRenderer.SetVertexCount(0);
lineRenderer.SetColors(Color.white, Color.white);
float sevenTwo = 72 * Mathf.Deg2Rad;
points = new List<GameObject>();
clearedPoints = new List<Vector3>();
for (int i = 0; i < 5; i++)
{
float ang = Mathf.PI * 3 / 2 + sevenTwo * i;
Vector3 pos = new Vector3(Mathf.Cos(ang), Mathf.Sin(ang), 0) * radius;
GameObject newPoint = GameObject.Instantiate(pentPoint);
newPoint.transform.position = pos;
newPoint.GetComponent<PentagramPointController>().controller = this;
points.Add(newPoint);
}
for (int i = 0; i < 5; i++)
{
points[i].GetComponent<PentagramPointController>().pair = points[(i + 3) % 5].GetComponent<PentagramPointController>();
}
points[0].GetComponent<PentagramPointController>().select(true);
}
示例12: reset
public void reset()
{
startPos.x = 0;
startPos.y = 0;
startPos.z = 0;
endPos.x = 0;
endPos.y = 0;
endPos.z = 0;
penDown = false;
sessionStart = false;
inSession = false;
localLRend = this.transform.gameObject.GetComponent<LineRenderer>();
localLRend.material = new Material(Shader.Find("Diffuse"));
localLRend.material.color = Color.black;
localLRend.castShadows = false;
localLRend.receiveShadows = false;
localLRend.SetVertexCount(2);
localLRend.SetWidth(lineThickness,lineThickness);
localLRend.SetColors(Color.black,Color.black);
localLRend.SetPosition(0,Vector3.zero);
localLRend.SetPosition(1,Vector3.zero);
localLRend.enabled = false;
}
示例13: Start
void Start()
{
left_index = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost);
right_index = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost);
right_linked = null;
left_linked = null;
// old_left_parent = null;
// old_right_parent = null;
left_offset = Vector3.zero; // useless
right_offset = Vector3.zero; // useless
//old_left_local = Vector3.zero;
// old_right_local = Vector3.zero;
left_line_renderer = left_controller.gameObject.AddComponent<LineRenderer>();
left_line_renderer.material = new Material(Shader.Find("Particles/Additive"));
left_line_renderer.SetColors(Color.red, Color.red);
left_line_renderer.SetWidth(0.02F, 0.02F);
left_line_renderer.SetVertexCount(2);
left_line_renderer.enabled = false;
right_line_renderer = right_controller.gameObject.AddComponent<LineRenderer>();
right_line_renderer.material = new Material(Shader.Find("Particles/Additive"));
right_line_renderer.SetColors(Color.red, Color.red);
right_line_renderer.SetWidth(0.02F, 0.02F);
right_line_renderer.SetVertexCount(2);
right_line_renderer.enabled = false;
// TODO: haptic feedback
// TODO: if it's pressed and it's not null, still grab the object
// set local position under the parent to 0/0/0
}
示例14: Start
// Use this for initialization
void Start()
{
GameObject lockedCrosshairImage = new GameObject();
Image crossHairImage = lockedCrosshairImage.AddComponent<Image>();
crossHairImage.rectTransform.pivot = new Vector2(0.5f,0.5f);
crossHairImage.rectTransform.anchorMax = Vector2.zero;
crossHairImage.rectTransform.anchorMin = Vector2.zero;
crossHairImage.rectTransform.sizeDelta = new Vector2(64,64);
crossHairImage.raycastTarget = false;
crossHairImage.sprite = trackingCrosshair;
crossHairImage.color = Color.black;
crossHairImage.type = Image.Type.Filled;
crossHairImage.fillMethod = Image.FillMethod.Radial360;
crossHairImage.fillAmount = 0;
//TODO get reference to the correct canvas
Canvas canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
crossHairImage.transform.SetParent(canvas.transform);
crossHairImage.transform.SetAsFirstSibling();
crossHairImage.transform.localScale = Vector3.one;
myTrackingCrosshair = crossHairImage;
myTargetingLine = myTrackingModule.gameObject.AddComponent<LineRenderer>();
myTargetingLine.useWorldSpace = true;
myTargetingLine.SetVertexCount(2);
myTargetingLine.SetPositions(new Vector3[]{Vector3.zero,Vector3.zero});
myTargetingLine.SetWidth(0.5f,0.5f);
myTargetingLine.SetColors(Color.red,Color.red);
myTargetingLine.enabled = false;
}
示例15: Start
// Use this for initialization
void Start()
{
lr = GetComponent<LineRenderer>();
if (!customColor)
{
if (hit) col = new Color(0,1,1,0.35f);
if (!hit) col = new Color(1,0.5f,0,0.35f);
}
lr.SetColors(col,col);
float distance = Vector3.Distance(start,end);
Vector3 direction = (end-start).normalized;
int stepCount = Mathf.FloorToInt(distance / 0.5f);
points = new Vector3[stepCount];
moves = new Vector3[stepCount];
for (int i=0; i<stepCount; i++){
points[i] = start + (direction * i * 0.5f);
points[i] += new Vector3(Random.Range(-Spread,Spread),Random.Range(-Spread,Spread),Random.Range(-Spread,Spread));
moves[i] = new Vector3(Random.Range(-Spread,Spread),Random.Range(-Spread,Spread),Random.Range(-Spread,Spread));
}
lr.SetVertexCount(points.Length+1);
for (int i=0; i<stepCount; i++){
lr.SetPosition(i,points[i]);
}
lr.SetPosition(points.Length,end);
//lr.SetPosition(0,start);
//lr.SetPosition(1,end);
}