need help , just a small question

Updated on July 30, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on July 30, 2018

So i am currently learning unity , found this code in a forum and i was wondering why did they add the ” ” and the _ in “_Color”

thanks.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bullshit : MonoBehaviour {
 public Color sphereColor;
// Use this for initialization
 void Start () {
 MeshRenderer MyRenderer = GetComponent<MeshRenderer>();
 Material spherematerial = new Material(MyRenderer.material);
 spherematerial.SetColor("_Color", sphereColor);
 MyRenderer.material = spherematerial;
 }
 // Update is called once per frame
 void Update () {
 }
}
  • Liked by
Reply
1 on July 30, 2018

That’s because Unity designed that part of the preset code that we pleebs can use. And they decided to let us change the color of materials with that syntax.

on July 30, 2018

thanks

Show more replies
  • Liked by
Reply
Cancel