コード例 #1
0
        public static void DrawPoint(Vector3 pos, UnityEngine.Color col, float scale)
        {
            if (isEnabled)
            {
                Vector3[] points = new Vector3[]
                {
                    pos + (Vector3.up * scale),
                    pos - (Vector3.up * scale),
                    pos + (Vector3.right * scale),
                    pos - (Vector3.right * scale),
                    pos + (Vector3.forward * scale),
                    pos - (Vector3.forward * scale)
                };

                DrawLine(points[0], points[1], col);
                DrawLine(points[2], points[3], col);
                DrawLine(points[4], points[5], col);

                DrawLine(points[0], points[2], col);
                DrawLine(points[0], points[3], col);
                DrawLine(points[0], points[4], col);
                DrawLine(points[0], points[5], col);

                DrawLine(points[1], points[2], col);
                DrawLine(points[1], points[3], col);
                DrawLine(points[1], points[4], col);
                DrawLine(points[1], points[5], col);

                DrawLine(points[4], points[2], col);
                DrawLine(points[4], points[3], col);
                DrawLine(points[5], points[2], col);
                DrawLine(points[5], points[3], col);
            }
        }
コード例 #2
0
        public static void DrawRect(Rect rect, UnityEngine.Color col)
        {
            if (isEnabled)
            {
                Vector3 pos   = new Vector3(rect.x + rect.width / 2, rect.y + rect.height / 2, 0.0f);
                Vector3 scale = new Vector3(rect.width, rect.height, 0.0f);

                DrawRect(pos, col, scale);
            }
        }
コード例 #3
0
 public static UnityEngine.Color[] GetColor(this Color[,] c, int w, int h)
 {
     UnityEngine.Color[] cs = new UnityEngine.Color[w * h];
     for (int i = 0; i < w; ++i)
     {
         for (int j = 0; j < h; ++j)
         {
             cs[i + j * w] = c[i, h - j - 1];
         }
     }
     return(cs);
 }
コード例 #4
0
    public static bool DrawButtonWithShadow(Rect r, GUIContent content, GUIStyle style, float shadowAlpha, Vector2 direction)
    {
        GUIStyle letters = new GUIStyle(style);

        letters.normal.background = null;
        letters.hover.background  = null;
        letters.active.background = null;
         
        bool result = GUI.Button(r, content, style);

        UnityEngine.Color color = r.Contains(Event.current.mousePosition) ? letters.hover.textColor : letters.normal.textColor;
         
        DrawShadow(r, content, letters, color, new UnityEngine.Color(0f, 0f, 0f, shadowAlpha), direction);

         
        return(result);
    }
コード例 #5
0
 public static void DrawRay(Vector3 start, Vector3 dir, UnityEngine.Color color = default(UnityEngine.Color), float duration = 0.0f, float width = 1.0f, bool depthTest = true)
 {
     if (color.Equals(default(UnityEngine.Color)))
     {
         color = DebugColor.normal;
     }
     if (isEnabled)
     {
         if (Application.isEditor && Application.isPlaying)
         {
             UnityEngine.Debug.DrawRay(start, dir, color, duration, depthTest);
         }
         if (Application.isPlaying && isGamingEnabled)
         {
             DebugLine.DrawRay(start, dir, color, duration, width);
         }
     }
 }
コード例 #6
0
        public static void DrawRect(Vector3 pos, UnityEngine.Color col, Vector3 scale)
        {
            if (isEnabled)
            {
                Vector3 halfScale = scale * 0.5f;

                Vector3[] points = new Vector3[]
                {
                    pos + new Vector3(halfScale.x, halfScale.y, halfScale.z),
                    pos + new Vector3(-halfScale.x, halfScale.y, halfScale.z),
                    pos + new Vector3(-halfScale.x, -halfScale.y, halfScale.z),
                    pos + new Vector3(halfScale.x, -halfScale.y, halfScale.z)
                };

                DrawLine(points[0], points[1], col);
                DrawLine(points[1], points[2], col);
                DrawLine(points[2], points[3], col);
                DrawLine(points[3], points[0], col);
            }
        }
コード例 #7
0
        public static Texture2D ToTexture(this UnityEngine.Color c, int w = 1, int h = 1)
        {
            if (w < 1 || h < 1)
            {
                throw new Exception("This method doesn't avoid zero or negative dimensions.");
            }
            Texture2D t = new Texture2D(w, h);

            if (w > 1 && h > 1)
            {
                for (int i = 0; i < w; ++i)
                {
                    for (int j = 0; j < h; ++j)
                    {
                        t.SetPixel(i, j, c);
                    }
                }
            }
            else if (w > 1 && h == 1)
            {
                for (int i = 0; i < w; ++i)
                {
                    t.SetPixel(i, 0, c);
                }
            }
            else if (w == 1 && h > 1)
            {
                for (int j = 0; j < h; ++j)
                {
                    t.SetPixel(0, j, c);
                }
            }
            else
            {
                t.SetPixel(0, 0, c);
            }
            t.Apply();
            return(t);
        }
コード例 #8
0
    public static void DrawShadow(Rect rect, GUIContent content, GUIStyle style, UnityEngine.Color txtColor, UnityEngine.Color shadowColor,
                                  Vector2 direction)
    {
        rect.x += direction.x;
        rect.y += direction.y;
        GUI.Label(rect, content, new GUIStyle(style)
        {
            normal = new GUIStyleState()
            {
                textColor = shadowColor
            }
        });
         
        rect.x -= direction.x;

        rect.y -= direction.y;
        GUI.Label(rect, content, new GUIStyle(style)
        {
            normal = new GUIStyleState()
            {
                textColor = txtColor
            }
        });
    }
コード例 #9
0
    public static void DrawOutline(Rect rect, string text, GUIStyle style, UnityEngine.Color outColor, UnityEngine.Color inColor, float size)
    {
        float    halfSize    = size * 0.5F;
        GUIStyle backupStyle = new GUIStyle(style);

        UnityEngine.Color backupColor = GUI.color;
         
        style.normal.textColor = outColor;

        GUI.color = outColor;
         
        rect.x -= halfSize;

        GUI.Label(rect, text, style);
         
        rect.x += size;

        GUI.Label(rect, text, style);
         
        rect.x -= halfSize;

        rect.y -= halfSize;
        GUI.Label(rect, text, style);
         
        rect.y += size;

        GUI.Label(rect, text, style);
         
        rect.y -= halfSize;

        style.normal.textColor = inColor;
        GUI.color = backupColor;
        GUI.Label(rect, text, style);
         
            style = backupStyle;
    }
コード例 #10
0
 public static string ColorToHex(this UnityEngine.Color color)
 {
     return(ColorToHex((Color32)color));
 }
コード例 #11
0
 public static void DrawLayoutShadow(GUIContent content, GUIStyle style, UnityEngine.Color txtColor, UnityEngine.Color shadowColor,
                                     Vector2 direction, params GUILayoutOption[] options)
 {
     DrawShadow(GUILayoutUtility.GetRect(content, style, options), content, style, txtColor, shadowColor, direction);
 }
コード例 #12
0
 public static void DrawLayoutOutline(string text, GUIStyle style, UnityEngine.Color outColor, UnityEngine.Color inColor, float size, params GUILayoutOption[] options)
 {
     DrawOutline(GUILayoutUtility.GetRect(new GUIContent(text), style, options), text, style, outColor, inColor, size);
 }