Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved 2022.2.0b7 - Handles.DrawWireCube not respecting Handles.color

Discussion in '2022.2 Beta' started by adamgolden, Sep 9, 2022.

  1. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,548
    I'm not sure how long this bug has existed, but I noticed it in the latest beta.

    Setting Handles.color does not work for Handles.DrawWireCube. It does for other things (as shown with DrawWireDisc).

    Handles_DrawWireCube_color_issue.jpg

    The repro below uses OnDrawGizmos, but I noticed this in a custom editor drawing in OnSceneGUI. Add to any GameObject with a MeshFilter and mesh:
    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEngine;
    3. using UnityEditor;
    4. public class ExampleDrawWireCubeColorBroken : MonoBehaviour
    5. {
    6.   private void OnDrawGizmos()
    7.   {
    8.     MeshFilter mf = GetComponent<MeshFilter>();
    9.     Handles.matrix = transform.localToWorldMatrix;
    10.     Mesh mesh = mf.sharedMesh;
    11.  
    12.     Handles.color = Color.red;
    13.  
    14.     Handles.DrawWireCube(mesh.bounds.center, mesh.bounds.size);
    15.     Handles.DrawWireDisc(mesh.bounds.center, Vector3.up, Mathf.Max(mesh.bounds.size.x, mesh.bounds.size.z) * 0.5f);
    16.   }
    17. }
    18. #endif
     
  2. adslitw

    adslitw

    Joined:
    Aug 23, 2012
    Posts:
    275
    Just came across this is 2022.1.16!
     
  3. killo0o

    killo0o

    Joined:
    Jan 7, 2017
    Posts:
    2
    Confirming issue stays on 2022.1.23f1
     
  4. Talimar

    Talimar

    Joined:
    Dec 28, 2012
    Posts:
    3
    Found this post because it's not working for me either... 2022.1.23f1
     
  5. diogo-valadares

    diogo-valadares

    Joined:
    Jun 25, 2020
    Posts:
    2
    yep, the same here on 2022.1.23f1
     
  6. adslitw

    adslitw

    Joined:
    Aug 23, 2012
    Posts:
    275
    I've submitted a bug for this, FYI.
     
    adamgolden likes this.
  7. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,548
    adslitw likes this.