public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { if (!is_init) { Init(prop); } EditorGUI.BeginChangeCheck(); if (EditorGUI.EndChangeCheck()) { Init(prop); } UpdateRects(position); if (ShaderEditor.input.MouseClick && border_position.Contains(Event.current.mousePosition)) { ShaderEditor.input.Use(); PropertyOptions options = ShaderEditor.currentlyDrawing.currentProperty.options; GradientEditor.Open(data, prop, options.texture, options.force_texture_options, !options.force_texture_options); } GuiHelper.drawSmallTextureProperty(position, prop, label, editor, DrawingData.currentTexProperty.hasFoldoutProperties); GradientField(); }
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { if (!is_init) { Init(prop); } EditorGUI.BeginChangeCheck(); GuiHelper.drawSmallTextureProperty(position, prop, label, editor, DrawingData.currentTexProperty.hasFoldoutProperties); if (EditorGUI.EndChangeCheck()) { Init(prop); } Rect border_position = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, Screen.width - EditorGUIUtility.labelWidth - position.x - EditorGUI.indentLevel * 15 - 10, position.height); Rect gradient_position = new Rect(border_position.x + 1, border_position.y + 1, border_position.width - 2, border_position.height - 2); Texture2D backgroundTexture = TextureHelper.GetBackgroundTexture(); Rect texCoordsRect = new Rect(0, 0, gradient_position.width / backgroundTexture.width, gradient_position.height / backgroundTexture.height); GUI.DrawTextureWithTexCoords(gradient_position, backgroundTexture, texCoordsRect, false); if (data.preview_texture != null) { TextureWrapMode wrap_mode = data.preview_texture.wrapMode; data.preview_texture.wrapMode = TextureWrapMode.Clamp; bool vertical = data.preview_texture.height > data.preview_texture.width; Vector2 pivot = new Vector2(); if (vertical) { pivot = new Vector2(gradient_position.x, gradient_position.y + gradient_position.height); GUIUtility.RotateAroundPivot(-90, pivot); gradient_position.y += gradient_position.height; float h = gradient_position.width; gradient_position.width = gradient_position.height; gradient_position.y += h; gradient_position.height = -h; } GUI.DrawTexture(gradient_position, data.preview_texture, ScaleMode.StretchToFill, true); if (vertical) { GUIUtility.RotateAroundPivot(90, pivot); } GUI.DrawTexture(border_position, data.preview_texture, ScaleMode.StretchToFill, false, 0, Color.grey, 1, 1); data.preview_texture.wrapMode = wrap_mode; } else { GUI.DrawTexture(border_position, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 0, Color.grey, 1, 1); } if (Event.current.type == EventType.MouseDown && border_position.Contains(Event.current.mousePosition)) { GradientEditor.Open(data, prop, !ThryEditor.currentlyDrawing.currentProperty.options.force_texture_options); } }
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { if (!is_init) { Init(prop); } EditorGUI.BeginChangeCheck(); editor.TexturePropertyMiniThumbnail(position, prop, label.text, label.tooltip); if (EditorGUI.EndChangeCheck()) { Init(prop); } Rect border_position = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, Screen.width - EditorGUIUtility.labelWidth - position.x - EditorGUI.indentLevel * 15 - 10, position.height); Rect gradient_position = new Rect(border_position.x + 1, border_position.y + 1, border_position.width - 2, border_position.height - 2); Texture2D backgroundTexture = Helper.GetBackgroundTexture(); Rect texCoordsRect = new Rect(0, 0, gradient_position.width / backgroundTexture.width, gradient_position.height / backgroundTexture.height); GUI.DrawTextureWithTexCoords(gradient_position, backgroundTexture, texCoordsRect, false); if (data.preview_texture != null) { TextureWrapMode wrap_mode = data.preview_texture.wrapMode; data.preview_texture.wrapMode = TextureWrapMode.Clamp; GUI.DrawTexture(gradient_position, data.preview_texture, ScaleMode.StretchToFill, true); GUI.DrawTexture(border_position, data.preview_texture, ScaleMode.StretchToFill, false, 0, Color.grey, 1, 1); data.preview_texture.wrapMode = wrap_mode; } else { GUI.DrawTexture(border_position, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 0, Color.grey, 1, 1); } if (Event.current.type == EventType.MouseDown && border_position.Contains(Event.current.mousePosition)) { GradientEditor.Open(data, prop, !ThryEditor.currentlyDrawing.currentProperty.options.force_texture_options); } }
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { if (!is_init) { Init(prop); } EditorGUI.BeginChangeCheck(); GuiHelper.drawSmallTextureProperty(position, prop, label, editor, DrawingData.currentTexProperty.hasFoldoutProperties); if (EditorGUI.EndChangeCheck()) { Init(prop); } UpdateRects(position); GradientField(); if (Event.current.type == EventType.MouseDown && border_position.Contains(Event.current.mousePosition)) { GradientEditor.Open(data, prop, !ThryEditor.currentlyDrawing.currentProperty.options.force_texture_options); } }