본문 바로가기
개발/Unity

Unity) Unity Editor Default Background Color (GetDefaultbackgroundColor)

by 테샤르 2022. 6. 13.

Unity Editor Default Background Color (GetDefaultbackgroundColor)

Unity 에서 Custom Editor를 만드는 과정에서

 

라이선스에 따라 Unity Skin Color 가 변경되는 값으로 인해서 특정 컬러를 사용할 경우 이질적으로 보여서 검색하다가 찾은걸 기록한다.

 

 

반응형

기본적으로 Pro 라이선스일경우에는 '블랙'에 가까운 컬러고 아닌 경우에는 '회색'에 가까운 컬러이다.

 

Unity 내부 코드에 있는 GetDefaultBackgroundColor를 가져 온다.

Unity 내부 GetDefaultBackgroundColor 링크 : [링크]

 

GitHub - Unity-Technologies/UnityCsReference: Unity C# reference source code.

Unity C# reference source code. Contribute to Unity-Technologies/UnityCsReference development by creating an account on GitHub.

github.com

 private static Color GetDefaultBackgroundColor()
 {
     float kViewBackgroundIntensity = isProSkin ? 0.22f : 0.76f;
     return new Color(kViewBackgroundIntensity, kViewBackgroundIntensity, kViewBackgroundIntensity, 1f);
 }
 private static Color _DefaultBackgroundColor;
 public static Color DefaultBackgroundColor
 {
     get
     {
         if (_DefaultBackgroundColor.a == 0)
         {
             var method = typeof(EditorGUIUtility)
                 .GetMethod("GetDefaultBackgroundColor", BindingFlags.NonPublic | BindingFlags.Static);
             _DefaultBackgroundColor = (Color)method.Invoke(null, null);
         }
         return _DefaultBackgroundColor;
     }
 }

 

원본 링크 : [ 링크 ]

 

Is there a way to get Editor background color? - Unity Answers

 

answers.unity.com

 

 

★☆☆☆☆

 

반응형

댓글