Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

material Array setter

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MaterialArraySetter : MonoBehaviour {

    public Material Material1;

    void Start ()
    {
        Material[] materialsArray = GetComponent<Renderer>().materials;
        materialsArray[1] = Material1;
        GetComponent<Renderer>().materials = materialsArray;

    }

}
Source by gamedev.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #material #Array #setter
ADD COMMENT
Topic
Name
6+6 =