Results 1 to 3 of 3
  1. #1
    [NEWACCOUNT]Yano's Avatar
    Join Date
    Dec 2014
    Gender
    male
    Location
    CL_WritePacket();
    Posts
    305
    Reputation
    13
    Thanks
    5,011
    My Mood
    Relaxed

    Post UnityEngine Drawing Class C#

    Sup guys!
    I coded a small Drawing Class for Unity C#:
    Just put this into a new .cs file in your Unity Hack.

    Code:
    /////////////////////// YDrawing.cs //////////////////
    using System;
    using System.Collections.Generic;
    using System.Threading;
    using UnityEngine;
    
    
    namespace DrawDev
    {
    
        class DrawDevice
        {
    
            public static Material lineMaterial;
            public static bool intialized = false;
            private static float CorrectY(float value)
            {
    
                return (Screen.height / 2 - value) + Screen.height / 2;
    
            }      
            public static void DrawLine(Vector2 pointA, Vector2 pointB, Color color)
            {
    
                lineMaterial.SetPass(0);
                GL.Begin(1);
                GL.Color(color);
                GL.Vertex3(pointA.x, pointA.y, 0f);
                GL.Vertex3(pointB.x, pointB.y, 0f);
                GL.End();
    
            }
            public static void DrawRect(Vector2 Point, int width,int height,Color color)
            {            
                DrawLine(Point, new Vector2(Point.x + width, Point.y),color);
                DrawLine(Point, new Vector2(Point.x, Point.y + height), color);
                DrawLine(new Vector2(Point.x + width, Point.y + height), new Vector2(Point.x + width, Point.y), color);
                DrawLine(new Vector2(Point.x + width, Point.y + height), new Vector2(Point.x, Point.y + height), color);
            }
            public static void DrawTriangle(Vector2 Point, int left, int right, int height, Color color)
            {
    
                DrawLine(Point, new Vector2(Point.x - left, Point.y + height), color);
                DrawLine(Point, new Vector2(Point.x + right, Point.y + height), color);
                DrawLine(new Vector2(Point.x - left, Point.y + height), new Vector2(Point.x + right, Point.y + height), color);
    
            }
            public static void DrawCross(Vector2 Point, int width, int height, Color color)
            {
    
                DrawLine(new Vector2(Point.x - width, Point.y), new Vector2(Point.x + width, Point.y),color);
                DrawLine(new Vector2(Point.x, Point.y - height), new Vector2(Point.x, Point.y + height), color);
    
            }
            public static void DrawCircle(Vector2 Point, int radius, Color color)
            {
    
                 double PI = 3.1415926535;
                 double i, x1, y1;
                 double angle;
                 
    
                 for (i = 0; i < 360; i += 1)
                 {
                     angle = i;
                     x1 = radius * Math.Cos(angle * PI / 180);
                     y1 = radius * Math.Sin(angle * PI / 180);
                     DrawLine(new Vector2(Point.x + Convert.ToSingle(x1), Point.y + Convert.ToSingle(y1)),new Vector2(Point.x + 1 + Convert.ToSingle(x1), Point.y + 1 + Convert.ToSingle(y1)),color);
                 }
                 
    
            }
            public static void DrawFont(Vector2 Point,int width,int height, string txt,Color color)
            {
                Color old = GUI.contentColor;
                GUI.contentColor = color;
                GUI.Label(new Rect(Point.x, Point.y, width, height), txt);
                GUI.contentColor = old;
            }
            public static void FillRGB(Vector2 point, float width, float height, Color color, float alpha)
            {
    
                Texture2D rgb = new Texture2D(1, 1);
    
                Color fillColor = color;
                fillColor.a = alpha;
                var fillColorArray =  rgb.GetPixels();
    
                for (var i = 0; i < fillColorArray.Length; ++i)
                {
                    fillColorArray[i] = fillColor;
                }
    
                rgb.SetPixels(fillColorArray);
                rgb.Apply();
                GUI.DrawTexture(new Rect(point.x, point.y, width, height), rgb);
    
                
                
            } //Sometimes game crashes for me
            
            public static void Intialize()
            {
    
                lineMaterial = new Material("Shader \"Lines/Colored Blended\" {SubShader { Pass {   BindChannels { Bind \"Color\",color }   Blend SrcAlpha OneMinusSrcAlpha   ZWrite Off Cull Off Fog { Mode Off }} } }");
                lineMaterial.hideFlags = HideFlags.HideAndDontSave;
                lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
    
                intialized = true;
    
            }
    
        }
    
    }
    How to initialize:
    Code:
    if (DrawDevice.intialized == false) DrawDevice.Intialize();
    How to use:
    Code:
    using DrawDev;
    DrawDevice.DrawLine(new Vector2(20,20), new Vector2(200,200), Color.Red);
    Screenshot:

  2. The Following 5 Users Say Thank You to [NEWACCOUNT]Yano For This Useful Post:

    HacxXcoder_Death (04-19-2018),Kr4ken (11-16-2015),Nextgencheat (03-26-2018),stephD (02-07-2016),Zaczero (12-10-2015)

  3. #2
    Nextgencheat's Avatar
    Join Date
    Mar 2018
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    0
    My Mood
    Chatty
    Thanks for this helpful post man

  4. #3
    stevevue339's Avatar
    Join Date
    Jun 2018
    Gender
    male
    Posts
    16
    Reputation
    10
    Thanks
    1
    cool stuff

Similar Threads

  1. [Drawing] Cool, Cute, and Funny drawing from 2012
    By Nathalie in forum Art & Graphic Design
    Replies: 4
    Last Post: 06-16-2014, 02:57 AM
  2. [Drawing] Drawing Pad
    By Rance-Llama in forum Art & Graphic Design
    Replies: 7
    Last Post: 05-11-2014, 02:34 AM
  3. [Drawing] Can someone hand draw this
    By Observation in forum Help & Requests
    Replies: 0
    Last Post: 10-10-2013, 02:54 PM
  4. Just a random drawing I did in class
    By Domo in forum Art & Graphic Design
    Replies: 6
    Last Post: 07-26-2012, 03:00 PM
  5. [various] Math Class drawings!
    By Mokou-Sama in forum Art & Graphic Design
    Replies: 25
    Last Post: 06-03-2011, 12:22 PM