Skin Change
##Shader/Material change
When building UI elements it would be great if I could do quick shader or material changes across multiple elements. Currently, I duplicate the materials and change all the elements by hand. Would be great if it could be done on a scene by scene basis.
##Skin changer
UI controller to input a Model that its referencing with a component to change between different colors, materials quickly. Perhaps a selection tool that could find "x" model to reference "x" material To also have a color changer for Text mesh pro would be amazing.
Describe alternatives you've considered
Perhaps a selection tool that could find "x" model to reference "x" Material. Which contains different materials.
Additional context
Add any other context or screenshots about the feature request here.
o if we can add a section for audio that would be great too!
@killerantz I have some faint memory of you working on something like this. Is this already possible?
To restate for my own understanding. Feature 1 - Material Find and Replace
- Create a new material
- Select an object in the scene - if no object selected then we will search everything in the scene
- Open the UI to find and replace materials
- Field 1 - Search For: Assign a reference object with the material I want to change - or the actual material could go here.
- Field 2 - Replace: Assign the new material I would like to change to
- Press Find and Replace, the script will search to find any objects with the material to find, then replace that material slot with the replace material.
I haven't done this specifically, I've changed fonts and materials on selected objects.
Here's some shader swapping code - which converts all the project materials with Unity standard shader to MRTK Standard Shader.
[MenuItem("Mixed Reality Toolkit/Materials/Unity Standard To MRTK Standard", false, 100)]
private static void UnityStandardToMRTKStandard()
{
Shader standard = Shader.Find("Mixed Reality Toolkit/Standard");
Shader unityStandard = Shader.Find("Standard");
Debug.Log("Shaders Found:\n Standard [" + (standard != null) + "], Unity Standard [" + (unityStandard != null) + "]");
#if UNITY_EDITOR
string[] materials = AssetDatabase.FindAssets("t:material");
int count = 0;
for (int i = 0; i < materials.Length; i++)
{
string assetPath = AssetDatabase.GUIDToAssetPath(materials[i]);
Material mat = (Material)AssetDatabase.LoadAssetAtPath(assetPath, typeof(Material));
if (mat != null && mat.shader == unityStandard)
{
mat.shader = standard;
Debug.Log("CHANGED: " + mat.name + " [ " + mat.shader + " ] ");
count++;
}
}
Debug.Log("Total Changed: " + count);
AssetDatabase.SaveAssets();
#endif
}
Feature 2 - Easy way to change colors and other properties globally - similar to style sheets This may be one solution to the problem with managing large UIs where we use placesholder colors then those values need to change later.
This I've done a lot of. Some of it is the foundation of the Interactable theming system. The color theme doesn't care what king of component it targets, a renderer, Text, TextMesh or TextMeshPro, it knows how to set the color on the object it's assigned to.
Any system like this does require some setup and planning, just like style sheets.
Some context, a colleague showed me this talk from Ryan Hipple (Unite Austin 2017) about using scriptableObjects unstead of singletons to manage global data. https://www.youtube.com/watch?time_continue=23&v=raQ3iHhE_Kk&feature=emb_logo
That same colleague wrote a package we use in our studio that allows us to save core theme properties in scriptable objects; properties like color. Then all objects that we want to subscribe to those colors have a component that references the scriptable object. In the case of Header Text, we have a Text scriptable object that has font, font size, font color fields. All the header text objects in the project have a component that references the HeaderText scriptableObject and applies the values. Whenever those values are changed in the scriptableObject, they are instantly changed on the subscribed component. We have components for Text, Colors, Scales, Rotations and Depth
This allows us to abstract out some of the core properties of the UI, that we know may change and effect a lot of internal components.
My colleague took things one step further and said, "what if I have two or more header text styles that I want to switch between, like some apps allow you to switch the theme of the whole app?" The Text scriptableObject has an override slot where another Text Scriptable object can be placed. This allows us to create one default HeaderText theme, then have a few alternate themes that can be applied at any time and update the look of the app.
Then we took things even beyond that and created a system that allows a scriptableObject to act kind of like singleton, which allows one button or one call to switch the current global theme. Similar to swapping out a style sheet.
You could use the theme collection tool to do this, which is now in Graphics Tools: https://github.com/microsoft/MixedReality-GraphicsTools-Unity/blob/public/0.4.x/com.microsoft.mrtk.graphicstools.unity/Runtime/Utilities/ThemeCollection.cs
Closing this for MRTK v2.x. The graphics tools package is utilized in MRTK3.