public static void OnSceneReflectUnityEngineMaterial(SceneExplorerState state, ReferenceChain refChain, Material material) { if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain)) { return; } if (material == null) { SceneExplorerCommon.OnSceneTreeMessage(refChain, "null"); return; } ReferenceChain oldRefChain = refChain; foreach (var prop in textureProps) { if (!material.HasProperty(prop)) { continue; } var value = material.GetTexture(prop); if (value == null) { continue; } refChain = oldRefChain.Add(prop); var type = value.GetType(); GUILayout.BeginHorizontal(); GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1)); GUIExpander.ExpanderControls(state, refChain, type); GUI.contentColor = ModTools.Instance.config.typeColor; GUILayout.Label(type.ToString() + " "); GUI.contentColor = ModTools.Instance.config.nameColor; GUILayout.Label(prop); GUI.contentColor = Color.white; GUILayout.Label(" = "); GUI.contentColor = ModTools.Instance.config.valueColor; GUILayout.Label(value.ToString()); GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); GUIButtons.SetupButtons(type, value, refChain); object paste; var doPaste = GUIButtons.SetupPasteButon(type, out paste); GUILayout.EndHorizontal(); if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain)) { GUIReflect.OnSceneTreeReflect(state, refChain, value); } if (doPaste) { material.SetTexture(prop, (Texture)paste); } } foreach (string prop in colorProps) { if (!material.HasProperty(prop)) { continue; } Color value = material.GetColor(prop); refChain = oldRefChain.Add(prop); var type = value.GetType(); GUILayout.BeginHorizontal(); GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1)); GUIExpander.ExpanderControls(state, refChain, type); GUI.contentColor = ModTools.Instance.config.typeColor; GUILayout.Label(type.ToString() + " "); GUI.contentColor = ModTools.Instance.config.nameColor; GUILayout.Label(prop); GUI.contentColor = Color.white; GUILayout.Label(" = "); var f = value; GUI.contentColor = ModTools.Instance.config.valueColor; var propertyCopy = prop; GUIControls.ColorField(refChain.ToString(), "", ref f, 0.0f, null, true, true, color => { material.SetColor(propertyCopy, color); }); if (f != value) { material.SetColor(prop, f); } GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); GUIButtons.SetupButtons(type, value, refChain); object paste; var doPaste = GUIButtons.SetupPasteButon(type, out paste); GUILayout.EndHorizontal(); if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain)) { GUIReflect.OnSceneTreeReflect(state, refChain, value); } if (doPaste) { material.SetColor(prop, (Color)paste); } } GUIReflect.OnSceneTreeReflect(state, refChain, material, true); }
public static void OnSceneReflectUnityEngineMaterial(SceneExplorerState state, ReferenceChain refChain, Material material) { if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain)) { return; } if (material == null) { SceneExplorerCommon.OnSceneTreeMessage(refChain, "null"); return; } ReferenceChain oldRefChain = refChain; foreach (var prop in textureProps) { if (!material.HasProperty(prop)) { continue; } var value = material.GetTexture(prop); if (value == null) { continue; } refChain = oldRefChain.Add(prop); var type = value.GetType(); GUILayout.BeginHorizontal(); GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1)); GUIExpander.ExpanderControls(state, refChain, type); GUI.contentColor = ModTools.Instance.config.typeColor; GUILayout.Label(type.ToString() + " "); GUI.contentColor = ModTools.Instance.config.nameColor; GUILayout.Label(prop); GUI.contentColor = Color.white; GUILayout.Label(" = "); GUI.contentColor = ModTools.Instance.config.valueColor; GUILayout.Label(value.ToString()); GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); GUIButtons.SetupButtons(type, value, refChain); object paste; var doPaste = GUIButtons.SetupPasteButon(type, out paste); GUILayout.EndHorizontal(); if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain)) { GUIReflect.OnSceneTreeReflect(state, refChain, value); } if (doPaste) { material.SetTexture(prop, (Texture)paste); } } foreach (string prop in colorProps) { if (!material.HasProperty(prop)) { continue; } Color value = material.GetColor(prop); refChain = oldRefChain.Add(prop); var type = value.GetType(); GUILayout.BeginHorizontal(); GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1)); GUIExpander.ExpanderControls(state, refChain, type); GUI.contentColor = ModTools.Instance.config.typeColor; GUILayout.Label(type.ToString() + " "); GUI.contentColor = ModTools.Instance.config.nameColor; GUILayout.Label(prop); GUI.contentColor = Color.white; GUILayout.Label(" = "); var f = value; GUI.contentColor = ModTools.Instance.config.valueColor; var propertyCopy = prop; GUIControls.ColorField(refChain.ToString(), "", ref f, 0.0f, null, true, true, color => { material.SetColor(propertyCopy, color); }); if (f != value) { material.SetColor(prop, f); } GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); GUIButtons.SetupButtons(type, value, refChain); object paste; var doPaste = GUIButtons.SetupPasteButon(type, out paste); GUILayout.EndHorizontal(); if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain)) { GUIReflect.OnSceneTreeReflect(state, refChain, value); } if (doPaste) { material.SetColor(prop, (Color)paste); } } // GUILayout.BeginHorizontal(); // GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1)); // GUI.contentColor = ModTools.Instance.config.typeColor; // // GUILayout.Label("Shader:"); // // GUI.contentColor = ModTools.Instance.config.nameColor; // // var shaders = Resources.FindObjectsOfTypeAll<Shader>(); // Array.Sort(shaders, (a, b) => string.Compare(a.name, b.name, StringComparison.Ordinal)); // var availableShaders = shaders.Select(s => s.name).ToArray(); // var currentShader = material.shader; // var selectedShader = Array.IndexOf(shaders, currentShader); // // var newSelectedShader = GUIComboBox.Box(selectedShader, availableShaders, "SceneExplorerShadersComboBox"); // if (newSelectedShader != selectedShader) // { // material.shader = shaders[newSelectedShader]; // } // GUILayout.FlexibleSpace(); // GUILayout.EndHorizontal(); GUIReflect.OnSceneTreeReflect(state, refChain, material, true); }