My idea was to mark some materials in the scene and make them configurable by user.
I guess there are many product configurators are based on this idea. I think product configurators are one of typical non-game uses of Unity, but I haven’t seen any template on the AssetStore or anywhere else yet.
The template used for this demo enables user to create custom texture palette based on uploaded images. Thanks to new advances in webgl and browsers technology the file uploads has now become easy and can be done through opening the system file dialog or drag&drop.
This could be particularly useful for exhibithion walls and stands, where client could see his own graphics placed on the product.
Generally the template should include some configuration options for the materials in Unity, like texture collections. (I mean some set of textures for the floor, other for the walls etc.) In this case I have concentrated on the uploads palette only. You can also setup in Editor the active materials as unique or shared, i. e. whether the app should create a unique material instance for each material occurence in the scene, or use shared material for all occurences.
The texture change on object issues the callback used by reflection probe manager to rebake reflection maps. It is just the purpose of the metallic boxes to illustrate that.
I just wonder whether that could be useful on the AssetStore.
I would just be very grateful for any feedback or suggestions on that.
Obviously the full version should include multiple palettes (not uploads only) and save/load functionality, this demo here would be just a start. Demo link here.
This is a trivial case.
I guess it is a mesh with 6 submeshes.
You have just 6 materials, one material per submesh.
The materials share the same common properties, only the tint colors are different.
You have a vertical selection grid to select the material and you have a horizontal selection grid to set color for the selected material and that’s all.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VerySimpleConfigurator : MonoBehaviour
{
private Material selectedMaterial;
public Material[] colourableMaterials; //put GameObject materials here
public Color[] colors; //put colors here
void Start () {
}
public void SelectMaterial (int i) {
selectedMaterial = colourableMaterials[i];
}
public void SetColor(int i)
{
selectedMaterial.color = colors[i];
}
}
You will only need to tie the GUI buttons to that.
Hi @tomekkie2 , i follow the way you did but come out with some errors. Can you explain the meaning of private class that you insert for material? Also, is it possible to insert GameObject array like you did for material and colour?
NullReferenceException: Object reference not set to an instance of an object
ColourConfigurator.SetColor (Int32 i) (at Assets/Scripts/ColourConfigurator.cs:22)
Below is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ColourConfigurator : MonoBehaviour
{
private Material selectedMaterial;
public Material[] colourableMaterials;
public Color[] colors = { Color.red, Color.blue, Color.green, Color.yellow }; //put colors here
void Start()
{
}
public void SelectMaterial(int i)
{
selectedMaterial = colourableMaterials[i];
}
public void SetColor(int i)
{
selectedMaterial.color = colors[i];
}
}