Advertisement
Denisimus

Untitled

Jul 19th, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. Vector2 size = new Vector2(detection.brx - detection.tlx, detection.bry - detection.tly);
  2. Vector2 pivot = new Vector2(detection.tlx, imageTexture.height - detection.bry);
  3.  
  4. // Create a new frame GameObject
  5. GameObject frame = new GameObject("Frame_" + detection.id);
  6. frame.transform.SetParent(transform);
  7.  
  8. // Add an Image component to the frame GameObject
  9. Image frameImage = frame.AddComponent<Image>();
  10. frameImage.color = frameColor;
  11.  
  12. frameImage.rectTransform.sizeDelta = size;
  13. frameImage.rectTransform.pivot = Vector2.zero;
  14.  
  15. // Position the frame correctly
  16. frame.transform.position = pivot;
  17.  
  18. // Get the rotation for the frame
  19. Quaternion frameRotation = Quaternion.Euler(detection.rotation);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement