private void DrawTarget(Rect r) { var textureSize = new Vector2(Mathf.Min(r.width, 1024.0f), Mathf.Min(r.height, 1024.0f)); var previewTexture = GradationMaterialEditor.CreatePreviewTexture2D(previewRender, material, textureSize, r.size, Color.white, Color.gray); GUI.DrawTexture(r, previewTexture); }
public override void OnPreviewGUI(Rect r, GUIStyle background) { base.OnPreviewGUI(r, background); if (Event.current.type != EventType.Repaint) { return; } var drawShortLength = Mathf.Min(r.width, r.height); var drawSize = drawShortLength * ((40.0f < drawShortLength)? 1.0f: 4.0f) * Vector2.one; var previewTexture = GradationMaterialEditor.CreatePreviewTexture2D((GradationMaterial)target, drawSize, Color.white, Color.gray); var drawRect = new Rect(r.center - drawShortLength * 0.5f * Vector2.one , drawShortLength * Vector2.one ); GUI.DrawTexture(drawRect, previewTexture); }