- Home /
,EditorGUI.DrawPreviewTexture has a problem
I'm using EditorGUI.DrawPreviewTexture(), and I want to draw an image on the Inspector. However, the drawing results in an error. The transparent part of the image is filled with the color of the border. I don't know how to fix it.
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
Texture2D oriTexture = (Texture2D)(property.FindPropertyRelative("texture").objectReferenceValue);
EditorGUI.DrawPreviewTexture(new Rect(position.x, position.y, oriTexture.width, oriTexture.height), oriTexture);
}
,I'm using EditorGUI.DrawPreviewTexture(), I want to draw an image on the Inspector. However, the drawing results in an error. The transparent part of the image is filled with the color of the border. I don't know how to fix it.
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label){ Texture2D oriTexture = (Texture2D)(property.FindPropertyRelative("texture").objectReferenceValue); EditorGUI.DrawPreviewTexture(new Rect(position.x, position.y, oriTexture.width, oriTexture.height), oriTexture); }
Your answer
![](https://koobas.hobune.stream/wayback/20220613043322im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
UnityEditor.Animations.AnimatorControllerLayer.SetOverrideMotion not working 0 Answers
Incoming Network connections stopped working for Unity Editor. 0 Answers
Legacy Animations Broken Behavior in Animation Tab (Unity 5) 1 Answer
How do I change the default application used to open logs from the Unity editor? (on Mac) 1 Answer
UnityEditor on Tag Update event 0 Answers