Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Material.GetVector

GetVector(propertyName: string): Vector4;
Vector4 GetVector(string propertyName);
def GetVector(propertyName as string) as Vector4
GetVector(nameID: int): Vector4;
Vector4 GetVector(int nameID);
def GetVector(nameID as int) as Vector4

Description

Get a named vector value.

Four component vectors and colors are the same in Unity shaders. GetVector does exactly the same as GetColor just the input data type is different (xyzw in the vector becomes rgba in the color).

See Also: GetColor, SetVector, Shader.PropertyToID.

	print(renderer.material.GetVector("_Color"));
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        print(renderer.material.GetVector("_Color"));
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Example() as void:
		print(renderer.material.GetVector('_Color'))