Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active June 30, 2017 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/993f5f00b15dd2ccfcb5e5c2ca6f0cb9 to your computer and use it in GitHub Desktop.
Save flushpot1125/993f5f00b15dd2ccfcb5e5c2ca6f0cb9 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LineRendererTest1-2 : MonoBehaviour {
private LineRenderer lr;
private Renderer rn;
void Start () {
lr = GetComponent<LineRenderer>();
lr.SetVertexCount(4);
lr.SetWidth(0.2f,0.2f);
lr.SetPosition(0,new Vector3(-7.0f,-2.0f,25.0f));
lr.SetPosition(1,new Vector3(14.0f,-2.0f,25.0f));
lr.SetPosition(2,new Vector3(-7.0f,-2.0f,25.0f));
lr.SetPosition(3, new Vector3(-7.0f,15.0f,25.0f));
rn = GetComponent<Renderer>();
// colorの範囲は0-1.0f。 ただし、Inspectorでは0-255で表示される
rn.material.SetColor("_Color",new Color(1.0f,0.0f,0.0f,1)); //R,G,B = 255,0,0,255に相当
//これを追加すると、Emissionの色を指定できる
rn.material.SetColor("_EmissionColor",new Color(1.0f,0.0f,0.0f));
//もしこのように書くと、Emissionが入ったような色表示になる。実行はできるがconsoleにはエラーが出る
/*
*Invalid normalized color: RGBA(255.000, 0.000, 0.000, 255.000), normalize value: 0 UnityEditor.DockArea:OnGUI()
*/
//rn.material.SetColor("_Color",new Color(255,0,0,255));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment