Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
fix upm & hdr colorpicker
Browse files Browse the repository at this point in the history
  • Loading branch information
lilxyzw committed Aug 19, 2021
1 parent cb6f356 commit 7ce77b5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
16 changes: 8 additions & 8 deletions Assets/lilFurGenerator/Editor/lilFurGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ void OnGUI()
GUIStyle customBox = GUI.skin.box;
GUIStyle customToggleFont = EditorStyles.label;
GUIStyle offsetButton = new GUIStyle(GUI.skin.button);
string mainFolderPath = GetMainFolderPath();
string editorFolderPath = GetEditorFolderPath();
if(EditorGUIUtility.isProSkin)
{
boxOuter = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_outer_2019.guiskin", typeof(GUISkin))).box);
boxInnerHalf = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_inner_half_2019.guiskin", typeof(GUISkin))).box);
boxInner = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_inner_2019.guiskin", typeof(GUISkin))).box);
customBox = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_custom_box_2019.guiskin", typeof(GUISkin))).box);
boxOuter = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_outer_2019.guiskin", typeof(GUISkin))).box);
boxInnerHalf = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_inner_half_2019.guiskin", typeof(GUISkin))).box);
boxInner = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_inner_2019.guiskin", typeof(GUISkin))).box);
customBox = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_custom_box_2019.guiskin", typeof(GUISkin))).box);
customToggleFont = EditorStyles.label;
offsetButton.margin.left = 24;
}
else
{
boxOuter = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_outer_2018.guiskin", typeof(GUISkin))).box);
boxInnerHalf = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_inner_half_2018.guiskin", typeof(GUISkin))).box);
boxInner = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_inner_2018.guiskin", typeof(GUISkin))).box);
boxOuter = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_outer_2018.guiskin", typeof(GUISkin))).box);
boxInnerHalf = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_inner_half_2018.guiskin", typeof(GUISkin))).box);
boxInner = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_inner_2018.guiskin", typeof(GUISkin))).box);
customBox = GUI.skin.box;
customToggleFont = new GUIStyle();
customToggleFont.normal.textColor = Color.white;
Expand Down
26 changes: 13 additions & 13 deletions Assets/lilFurGenerator/Editor/lilFurGeneratorInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ public enum lilRenderPipeline
public const string boothURL = "https://lilxyzw.booth.pm/";
public const string githubURL = "https://github.com/lilxyzw/lilFurGenerator";
public const string versionInfoURL = "https://raw.githubusercontent.com/lilxyzw/lilFurGenerator/master/version.json";
public const string mainFolderGUID = "edc3c051bb926d146b24e1b52d6615a5"; // "Assets/lilFurGenerator"
public const string editorFolderGUID = "59970fc0d266132478e5327940963258"; // "Assets/lilFurGenerator/Editor"
public const string languageFileGUID = "31b8eeba6110d59439de5782850a4574"; // "Assets/lilFurGenerator/Editor/lang.txt"
public const string fgShaderGUID = "2c540356c3ded7340b263ceb4ace7e37"; // "Assets/lilFurGenerator/Shader/lilFurGenerator.shader"
public const string hqfgShaderGUID = "7fc1943976840044e82d0503f1f70d23"; // "Assets/lilFurGenerator/Shader/lilFurGenerator.shader"
public const string fgShaderGUID = "2c540356c3ded7340b263ceb4ace7e37"; // "Assets/lilFurGenerator/Shader/lilFurGenerator.shader"
public const string hqfgShaderGUID = "7fc1943976840044e82d0503f1f70d23"; // "Assets/lilFurGenerator/Shader/lilFurGenerator.shader"
public const string editorSettingTempPath = "Temp/lilFurGeneratorEditorSetting";
public const string versionInfoTempPath = "Temp/lilFurGeneratorVersion";
public const string windowName = "lilFurGenerator";

public static string GetMainFolderPath()
public static string GetEditorFolderPath()
{
return AssetDatabase.GUIDToAssetPath(mainFolderGUID);
return AssetDatabase.GUIDToAssetPath(editorFolderGUID);
}

public static readonly Vector2 defaultTextureOffset = new Vector2(0.0f,0.0f);
Expand Down Expand Up @@ -170,21 +170,21 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
GUIStyle customBox = GUI.skin.box;
GUIStyle customToggleFont = EditorStyles.label;
GUIStyle offsetButton = new GUIStyle(GUI.skin.button);
string mainFolderPath = GetMainFolderPath();
string editorFolderPath = GetEditorFolderPath();
if(EditorGUIUtility.isProSkin)
{
boxOuter = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_outer_2019.guiskin", typeof(GUISkin))).box);
boxInnerHalf = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_inner_half_2019.guiskin", typeof(GUISkin))).box);
boxInner = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_inner_2019.guiskin", typeof(GUISkin))).box);
customBox = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_custom_box_2019.guiskin", typeof(GUISkin))).box);
boxOuter = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_outer_2019.guiskin", typeof(GUISkin))).box);
boxInnerHalf = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_inner_half_2019.guiskin", typeof(GUISkin))).box);
boxInner = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_inner_2019.guiskin", typeof(GUISkin))).box);
customBox = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_custom_box_2019.guiskin", typeof(GUISkin))).box);
customToggleFont = EditorStyles.label;
offsetButton.margin.left = 24;
}
else
{
boxOuter = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_outer_2018.guiskin", typeof(GUISkin))).box);
boxInnerHalf = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_inner_half_2018.guiskin", typeof(GUISkin))).box);
boxInner = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(mainFolderPath + "/Editor/gui_box_inner_2018.guiskin", typeof(GUISkin))).box);
boxOuter = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_outer_2018.guiskin", typeof(GUISkin))).box);
boxInnerHalf = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_inner_half_2018.guiskin", typeof(GUISkin))).box);
boxInner = new GUIStyle(((GUISkin)AssetDatabase.LoadAssetAtPath(editorFolderPath + "/gui_box_inner_2018.guiskin", typeof(GUISkin))).box);
customBox = GUI.skin.box;
customToggleFont = new GUIStyle();
customToggleFont.normal.textColor = Color.white;
Expand Down
23 changes: 23 additions & 0 deletions Assets/lilFurGenerator/Editor/lilFurGeneratorPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class lilHDRDrawer : MaterialPropertyDrawer
// [lilHDR]
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor)
{
float xMax = position.xMax;
position.width = Mathf.Min(position.width, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth);
Color value = prop.colorValue;
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = prop.hasMixedValue;
Expand All @@ -29,6 +31,27 @@ public override void OnGUI(Rect position, MaterialProperty prop, String label, M
{
prop.colorValue = value;
}

#if UNITY_2019_1_OR_NEWER
// Hex
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = prop.hasMixedValue;
float intensity = value.maxColorComponent > 1.0f ? value.maxColorComponent : 1.0f;
Color value2 = new Color(value.r / intensity, value.g / intensity, value.b / intensity, 1.0f);
string hex = ColorUtility.ToHtmlStringRGB(value2);
position.x += position.width + 4.0f;
position.width = Mathf.Max(50.0f, xMax - position.x);
hex = "#" + EditorGUI.TextField(position, GUIContent.none, hex);
if(EditorGUI.EndChangeCheck())
{
if(!ColorUtility.TryParseHtmlString(hex, out value2)) return;
value.r = value2.r * intensity;
value.g = value2.g * intensity;
value.b = value2.b * intensity;
prop.colorValue = value;
}
EditorGUI.showMixedValue = false;
#endif
}
}

Expand Down

0 comments on commit 7ce77b5

Please sign in to comment.