public void testMaterialEmission(roomVisualsMaterialChanger matChanger) { if (matChanger.mat == null) { return; } matChanger.mat.SetColor("_EmissionColor", matChanger.testMainEmissMatColor); }
public void resetToEmissionDefault(roomVisualsMaterialChanger matChanger) { if (matChanger.mat == null) { return; } matChanger.mat.SetColor("_EmissionColor", matChanger.defaultMainEmissMatColor); }
public roomVisualsMaterialChanger repackage() { roomVisualsMaterialChanger changer = new roomVisualsMaterialChanger(); changer.mat = (Material)material.objectReferenceValue ?? null; changer.testMainEmissMatColor = testEmissColor.colorValue; changer.defaultMainEmissMatColor = deafultEmissColour.colorValue; return(changer); }
void loadVisuals() { string path = EditorUtility.OpenFilePanel("Select a theme", "Assets", "asset"); //Making path relative to Assets folder if (path.StartsWith(Application.dataPath)) { path = "Assets" + path.Substring(Application.dataPath.Length); } roomVisualsHolder loadedHolder = AssetDatabase.LoadAssetAtPath <roomVisualsHolder>(path); if (loadedHolder == null) { return; } foreach (roomLightConfiguration lightConfig in loadedHolder.lightConfigurations) { roomVisualsLightsChanger lightChanger = helper.changers .Where(changer => changer.targetClassification == lightConfig.targetClassification) .FirstOrDefault(); if (lightChanger == null) { continue; } lightChanger.testIntensity = lightConfig.intensity; lightChanger.testRealTimeLightColor = lightConfig.realTimeLightColor; lightChanger.testRange = lightConfig.range; helper.testRealtimeLights(lightChanger); } foreach (roomMaterialConfiguration matConfig in loadedHolder.materialConfigurations) { roomVisualsMaterialChanger matChanger = helper.materialChangers .Where(changer => changer.mat == matConfig.mat) .FirstOrDefault(); if (matChanger == null) { continue; } matChanger.testMainEmissMatColor = matConfig.emissMatColor; helper.testMaterialEmission(matChanger); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { //Initializing the serialized properties... material = property.FindPropertyRelative("mat"); deafultEmissColour = property.FindPropertyRelative("defaultMainEmissMatColor"); testEmissColor = property.FindPropertyRelative("testMainEmissMatColor"); isExpanded = property.FindPropertyRelative("isExpanded"); autoUpdate = property.FindPropertyRelative("autoUpdate"); //Drawing the main label... label = EditorGUI.BeginProperty(position, label, property); //Allows us to have functionality like duplication within the array label.text = (material.objectReferenceValue == null) ? "Empty Changer" : ((Material)material.objectReferenceValue).name + " Changer"; EditorGUI.PrefixLabel(position, label); Rect currentPosition = position; currentPosition = EditorGUI.IndentedRect(currentPosition); //Applying the new indent to the position; currentPosition.height = 16; //Limiting the height for each property to 16 pixels currentPosition.y += 18; //Going to the next Line... isExpanded.boolValue = EditorGUI.Foldout(currentPosition, isExpanded.boolValue, "Expand"); currentPosition.y += 18; if (isExpanded.boolValue) { EditorGUI.PropertyField(currentPosition, material); currentPosition.y += 18; EditorGUI.PropertyField(currentPosition, deafultEmissColour); currentPosition.y += 18; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(currentPosition, testEmissColor); currentPosition.y += 18; EditorGUI.EndChangeCheck(); EditorGUI.PropertyField(currentPosition, autoUpdate); currentPosition.y += 18; roomVisualsMaterialChanger changer = repackage(); if (GUI.changed && autoUpdate.boolValue) { Object.FindObjectOfType <roomVisualsHelper>().testMaterialEmission(changer); } //The next two buttons will be on the same line, so I have to split currentPosition in 2 float originalX = currentPosition.x; currentPosition.width /= 2; if (GUI.Button(currentPosition, "Test onto Defualt")) { deafultEmissColour.colorValue = testEmissColor.colorValue; } currentPosition.x = currentPosition.xMax; if (GUI.Button(currentPosition, "Default onto Test")) { testEmissColor.colorValue = deafultEmissColour.colorValue; } currentPosition.x = originalX; currentPosition.y += 18; //Don't worry if material in changer is null, that is checked in roomVisualsHelper if (GUI.Button(currentPosition, "Apply Test")) { Object.FindObjectOfType <roomVisualsHelper>().testMaterialEmission(changer); } currentPosition.x = currentPosition.xMax; if (GUI.Button(currentPosition, "Apply Default")) { Object.FindObjectOfType <roomVisualsHelper>().resetToEmissionDefault(changer); } //Resoring currentPosition to it's normal size and position (incase I wanna add anything here later) currentPosition.x = originalX; currentPosition.width *= 2; } EditorGUI.EndProperty(); }