Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if UNITY_EDITOR
- private void OnDrawGizmos()
- {
- if (Prefab != null)
- {
- var icon = UnityEditor.AssetPreview.GetAssetPreview(Prefab);
- var matrix = GL.modelview; //Get the current View Matrix
- //Begin Insanity
- GL.PushMatrix();
- //Downscale the previous view matrix by 100
- GL.modelview = matrix * Matrix4x4.Scale(Vector3.one / 100f);
- //Center the icon bounds on the Game Object. Flip the Y-scale because.
- var rect = new Rect(transform.position - new Vector3(.5f, -.5f, 0), new Vector2(1, -1));
- //Upscale the rectangle bounds by 100
- rect.x *= 100;
- rect.y *= 100;
- rect.width *= 100;
- rect.height *= 100;
- //Draw the rest of the Owl
- Gizmos.DrawGUITexture(rect, icon);
- //End Insanity?
- GL.PopMatrix();
- Gizmos.color = Color.green;
- Gizmos.DrawWireCube(this.transform.position, Vector2.one);
- } else
- {
- Gizmos.color = Color.red;
- Gizmos.DrawCube(this.transform.position, Vector2.one);
- }
- }
- }
- #endif
Add Comment
Please, Sign In to add comment