I am having trouble just getting default Material values via Renderer.GetPropertyBlock()
. I only get ZEROS for all these properties. I got the property names from the debug view of the material.
Is there something I am doing wrong? I have tried this in unity 5.3 and 5.4, both are the same results.
using UnityEngine;
using System.Collections;
public class BugRepro : MonoBehaviour
{
void Start ()
{
MaterialPropertyBlock block = new MaterialPropertyBlock();
var renderer = GetComponent<MeshRenderer>();
renderer.GetPropertyBlock(block);
// BUG - These values are wrong! Why are they all ZERO?
print(string.Format("{0}: {1}", "_BumpScale", block.GetFloat("_BumpScale")));
print(string.Format("{0}: {1}", "_Cutoff", block.GetFloat("_Cutoff")));
print(string.Format("{0}: {1}", "_Glossiness", block.GetFloat("_Glossiness")));
print(string.Format("{0}: {1}", "_Metallic", block.GetFloat("_Metallic")));
print(string.Format("{0}: {1}", "_Parallax", block.GetFloat("_Parallax")));
}
void Update ()
{
}
}