File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #if UNITY_EDITOR
2+ using UnityEngine ;
3+ using System . Collections ;
4+ using UnityEngine . UI ;
5+ public class DebugUILine : MonoBehaviour
6+ {
7+ static Vector3 [ ] fourCorners = new Vector3 [ 4 ] ;
8+ void OnDrawGizmos ( )
9+ {
10+ foreach ( MaskableGraphic g in GameObject . FindObjectsOfType < MaskableGraphic > ( ) )
11+ {
12+ if ( g . raycastTarget )
13+ {
14+ RectTransform rectTransform = g . transform as RectTransform ;
15+ rectTransform . GetWorldCorners ( fourCorners ) ;
16+ Gizmos . color = Color . blue ;
17+ for ( int i = 0 ; i < 4 ; i ++ )
18+ Gizmos . DrawLine ( fourCorners [ i ] , fourCorners [ ( i + 1 ) % 4 ] ) ;
19+ }
20+ }
21+ }
22+ }
23+ #endif
Original file line number Diff line number Diff line change 1+ using UnityEngine ;
2+ using UnityEngine . UI ;
3+ using UnityEditor ;
4+
5+ public class MenuOptionOverwrite
6+ {
7+
8+ [ MenuItem ( "GameObject/UI/Image" ) ]
9+ static void CreateImage ( )
10+ {
11+ if ( Selection . activeTransform )
12+ {
13+ if ( Selection . activeTransform . GetComponentInParent < Canvas > ( ) )
14+ {
15+ GameObject go = new GameObject ( "image" , typeof ( Image ) ) ;
16+ go . GetComponent < Image > ( ) . raycastTarget = false ;
17+ go . transform . SetParent ( Selection . activeTransform ) ;
18+ }
19+ }
20+ }
21+
22+ [ MenuItem ( "GameObject/UI/Text" ) ]
23+ static void CreateText ( )
24+ {
25+ if ( Selection . activeTransform )
26+ {
27+ if ( Selection . activeTransform . GetComponentInParent < Canvas > ( ) )
28+ {
29+ GameObject go = new GameObject ( "text" , typeof ( Text ) ) ;
30+ go . GetComponent < Text > ( ) . raycastTarget = false ;
31+ go . transform . SetParent ( Selection . activeTransform ) ;
32+ }
33+ }
34+ }
35+
36+ }
You can’t perform that action at this time.
0 commit comments