Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

How to access material color through script?

A topic by saszer created 61 days ago Views: 36 Replies: 1
Viewing posts 1 to 2

Ive tried get component but failing,  any clues?

(1 edit)

This script is an example of setting the color from code. Is this along this lines of what you're looking for?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RaymarchingToolkit;
[RequireComponent(typeof(RaymarchObject))]
[ExecuteInEditMode]
public class ColorInput : MonoBehaviour
{
    RaymarchObject obj;
    public string InputName;
    public Color ColorValue;
    void Start()
    {
        obj = GetComponent<RaymarchObject>();
    }
    void Update()
    {
        var input = obj.GetMaterialInput(InputName);
        if (input != null) {
            input.color = ColorValue;
        }
    }
}