Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How to access material color through script?

A topic by saszer created Aug 18, 2019 Views: 293 Replies: 1
Viewing posts 1 to 3

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;
        }
    }
}