Пример #1
1
		public SerializedParticle (Vector3 position, 
		                           Vector3 velocity, 
		                           float rotation, 
		                           float size, 
		                           float lifetime, 
		                           float startLifetime, 
		                           float playgroundLife, 
		                           float playgroundStartLifetime, 
		                           float playgroundEndLifetime, 
		                           float playgroundLifetimeSubtraction, 
		                           Color32 color, 
		                           
		                           Vector3 sourcePosition,
		                           float startingSize
		                           )
		{
			this.position = position;
			this.velocity = velocity;
			this.rotation = rotation;
			this.size = size;
			this.lifetime = lifetime;
			this.startLifetime = startLifetime;
			this.playgroundLife = playgroundLife;
			this.playgroundStartLifetime = playgroundStartLifetime;
			this.playgroundEndLifetime = playgroundEndLifetime;
			this.playgroundLifetimeSubtraction = playgroundLifetimeSubtraction;
			this.color = color;
			
			this.sourcePosition = sourcePosition;
			this.startingSize = startingSize;
		}
Пример #2
1
		public void WriteRgbaColor(Color32 color)
		{
			Write(color.r);
			Write(color.g);
			Write(color.b);
			Write(color.a);
		}
Пример #3
0
 public void SerializeOut_color32(UnityEngine.Color32 c)
 {
     SerializeOut_byte(c.r);
     SerializeOut_byte(c.g);
     SerializeOut_byte(c.b);
     SerializeOut_byte(c.a);
 }
 public ColorXml(Color32 c)
 {
     this.r = c.r;
     this.g = c.g;
     this.b = c.b;
     this.a = c.a;
 }
Пример #5
0
    public void DrawAttkBox(SPoint[] v, string mat, int n, int endN, SPoint p, int pNum,  int t, int poly)
    {
        //specialized manual function for attackboxes
        subMesh [poly] = new Mesh ();
        int vTot = endN - n + 1;
        Vector3[] vertices = new Vector3[vTot];
        Color32[] col = new Color32[vTot];

        //std::stringstream hbName;
        string hbName = "P#" + pNum + "HB-" + t + "-" + poly;

        for (int i = n; i <= endN; i++) {
            vertices [i-n] = new Vector3 (v [i].x + p.x, v [i].y + p.y, 0);
            col [i-n] = new Color32 (0, 250, 20, 150);
        }
        int tTot = (vTot - 2) * 3;
        int[] tri = new int[tTot];
        for (int i = 0; i<(tTot/3);i++) {//triangle fan
            tri[i*3]=0;
            tri[(i*3)+1]=i+1;
            tri[(i*3)+2]=i+2;
        }
        subMesh[poly].vertices=vertices;
        subMesh[poly].triangles = tri;
        subMesh[poly].colors32 = col;
    }
Пример #6
0
	void Start() {

		winter = new Color32(246, 243, 237, 255);
		spring = new Color32(170, 155, 42, 255);
		summer = new Color32(137, 182, 65, 255);
		autumn = new Color32(234, 157, 46, 255);

		int currentSecond = DateTime.Now.Second;

		Camera _camera = GameObject.Find ("Main Camera").GetComponent<Camera>();
		childRenderers = this.transform.FindChild ("RoadsideGrass").GetComponentsInChildren<Renderer>();

		foreach (Renderer childRenderer in childRenderers) {
			if (currentSecond < 15) {
				_camera.backgroundColor = winter;
				childRenderer.material.color = winter;
			} 
			else if (currentSecond < 30) {
				_camera.backgroundColor = spring;
				childRenderer.material.color = spring;
			}
			else if (currentSecond < 45) {
				_camera.backgroundColor = summer;
				childRenderer.material.color = summer;
			} 
			else {
				_camera.backgroundColor = autumn ;
				childRenderer.material.color = autumn;
			}
		}
	}
 static public int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.Color32 o;
         if (argc == 5)
         {
             System.Byte a1;
             checkType(l, 2, out a1);
             System.Byte a2;
             checkType(l, 3, out a2);
             System.Byte a3;
             checkType(l, 4, out a3);
             System.Byte a4;
             checkType(l, 5, out a4);
             o = new UnityEngine.Color32(a1, a2, a3, a4);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc <= 2)
         {
             o = new UnityEngine.Color32();
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #8
0
 public void drawBoxAt(int leftSideX, int topSideY, int dimW, int dimH, Color32 useCol)
 {
     int left = leftSideX;
     int right = left+dimW;
     int top = topSideY;
     int bot = topSideY+dimH;
     if(left < 0) {
         left = 0;
     }
     if(top < 0) {
         top = 0;
     }
     if(right > screenWidth) {
         right = screenWidth;
     }
     if(bot > screenHeight) {
         bot = screenHeight;
     }
     for(int xp=left; xp <right; xp++) {
         for(int yp=top; yp <bot; yp++) {
             // paintThis.SetPixel(xp,yp,useCol);
             setBufferPixel(xp,yp,useCol);
         }
     }
 }
Пример #9
0
        /// <summary>
        /// Rotate the texture by a rotation and traslation matrix.
        /// </summary>
        /// <param name="textureArray"></param>
        /// <param name="phi"></param>
        /// <returns></returns>
        private void RotateSquare(float phi)
        {
            int x, y, xc, yc;
            float sin, cos;

            x = 0;
            y = 0;
            sin = Mathf.Sin(phi);
            cos = Mathf.Cos(phi);

            //pivot centered for the rotation
            //xc = width / 2;
            //yc = height / 2;

            //custom pivot
            xc = (int)_pivot.x;
            yc = (int)_pivot.y;

            for (int j = 0; j < _height; j++)
            {
                for (int i = 0; i < _width; i++)
                {
                    _newArray[j * _width + i] = new Color32(0, 0, 0, 0);

                    x = (int)(cos * (i - xc) + sin * (j - yc) + xc);
                    y = (int)(-sin * (i - xc) + cos * (j - yc) + yc);

                    if ((x > -1) && (x < _width) && (y > -1) && (y < _height))
                    {
                        _newArray[j * _width + i] = _oldArray[y * _width + x];
                    }
                }
            }       
        }
Пример #10
0
 public static void SetColor(this Slot slot, Color32 color)
 {
     slot.A = color.a / 255f;
     slot.R = color.r / 255f;
     slot.G = color.g / 255f;
     slot.B = color.b / 255f;
 }
Пример #11
0
 public static void SetColor(this RegionAttachment attachment, Color32 color)
 {
     attachment.A = color.a / 255f;
     attachment.R = color.r / 255f;
     attachment.G = color.g / 255f;
     attachment.B = color.b / 255f;
 }
Пример #12
0
	Color Hex2RGB(string hexColor){
		//Remove # if present
		if (hexColor.IndexOf('#') != -1)
			hexColor = hexColor.Replace("#", "");
		
		int red = 0;
		int green = 0;
		int blue = 0;
		
		if (hexColor.Length == 6)
		{
			//#RRGGBB
			red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier);
			green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier);
			blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier);
			
			
		}
		else if (hexColor.Length == 3)
		{
			//#RGB
			red = int.Parse(hexColor[0].ToString() + hexColor[0].ToString(), NumberStyles.AllowHexSpecifier);
			green = int.Parse(hexColor[1].ToString() + hexColor[1].ToString(), NumberStyles.AllowHexSpecifier);
			blue = int.Parse(hexColor[2].ToString() + hexColor[2].ToString(), NumberStyles.AllowHexSpecifier);
		}

        var color = new Color32((byte)red, (byte)green, (byte)blue, 255);
        return color;
		//return new Vector3 (red, green, blue);
	
	}
Пример #13
0
 // Update is called once per frame
 void Update()
 {
     float TimePassed = (Time.time - TimeStarted) / FadeTime;
     int FadeValue;
     int StartValue = 255;
     int EndValue = 0;
     if (!IsForward) {
         StartValue = 0;
         EndValue = 255;
     }
     FadeValue = Mathf.RoundToInt (Mathf.Lerp (StartValue, EndValue, TimePassed));
     Color32 NewBackgroundColor = new Color32(MyBackgroundColor.r,MyBackgroundColor.g,MyBackgroundColor.b,
                                              (byte)(FadeValue));
     gameObject.GetComponent<Renderer> ().material.color = NewBackgroundColor;
     //Time.timeScale = 0;
     if (FadeValue == EndValue) {
         if (IsForward) {
             //Time.timeScale = 1;
             gameObject.SetActive (false);
         } else {
             TimeStarted = Time.time+TimeDelay;
             IsForward = true;
         }
     }
 }
Пример #14
0
    void Start()
    {
        _texture = new Texture2D(Width, Height, TextureFormat.ARGB32, false);
        _texture.Apply(false, false);

        if (_movieCapture)
        {
            _movieCapture.SetSourceTexture(_texture);
        }

        _pixels = new Color32[Width*Height];
        _palette = new Color32[PaletteSize];

        Keyframe[] keysR = { new Keyframe(0f, 0f), new Keyframe(0.25f, 1f), new Keyframe(1f, 0f) };
        Keyframe[] keysG = { new Keyframe(0f, 1f), new Keyframe(0.5f, 0f), new Keyframe(1f, 1f) };
        Keyframe[] keysB = { new Keyframe(0f, 1f), new Keyframe(0.75f, 0f), new Keyframe(1f, 0f) };
        AnimationCurve curveR = new AnimationCurve(keysR);
        AnimationCurve curveG = new AnimationCurve(keysG);
        AnimationCurve curveB = new AnimationCurve(keysB);
        for (int i = 0; i < PaletteSize; i++)
        {
            float r = curveR.Evaluate((float)i / (float)PaletteSize);
            float g = curveG.Evaluate((float)i / (float)PaletteSize);
            float b = curveB.Evaluate((float)i / (float)PaletteSize);
            _palette[i] = new Color32((byte)(r * 255.0f), (byte)(g * 255.0f), (byte)(b * 255.0f), (byte)(b * 255.0f));
        }
    }
Пример #15
0
 public override void OnGazeEnter()
 {
     if(isSelectable)
     {
         destinationColor = selectedColor;
     }
 }
Пример #16
0
 public override void OnGazeExit()
 {
     if (isSelectable)
     {
         destinationColor = notSelectedColor;
     }
 }
    public override void DoCommand()
    {
        _oldColor = _editor.GetPalette().GetColor(_index);

        _editor.GetPalette().SetPaletteColor(_color, _index);
        _editor.GetPalette().RefreshPaletteTextureColors();
    }
Пример #18
0
		public void Set(int index, Color32 color)
		{
			components[index + 0] = color.r;
			components[index + 1] = color.g;
			components[index + 2] = color.b;
			components[index + 3] = color.a;
		}
    static int _CreateUnityEngine_Color32(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 4)
            {
                byte arg0 = (byte)LuaDLL.luaL_checknumber(L, 1);
                byte arg1 = (byte)LuaDLL.luaL_checknumber(L, 2);
                byte arg2 = (byte)LuaDLL.luaL_checknumber(L, 3);
                byte arg3 = (byte)LuaDLL.luaL_checknumber(L, 4);
                UnityEngine.Color32 obj = new UnityEngine.Color32(arg0, arg1, arg2, arg3);
                ToLua.PushValue(L, obj);
                return(1);
            }
            else if (count == 0)
            {
                UnityEngine.Color32 obj = new UnityEngine.Color32();
                ToLua.PushValue(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Color32.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #20
0
	private Color32[] mipmapImg(Color32[] src, int width, int height)
	{
		int newWidth = width / 2;
		int newHeight = height / 2;
		Color32[] dst = new Color32[newWidth * newHeight];
		Color32[] src1 = new Color32[width * height];
		for (int i = 0; i < src.Length; i += width) {
			for (int j = 0, k = width - 1; j < width; ++j, --k) {
				src1[i + j] = src[i + k];
			}
		}


		for(int yy = 0; yy < newHeight; yy++)
		{
			for(int xx = 0; xx < newWidth; xx++)
			{
				int TLidx = (xx * 2) + yy * 2 * width ;
				int TRidx = (xx * 2 + 1) + yy * width * 2;
				int BLidx = (xx * 2) + (yy * 2 + 1) * width;
				int BRidx = (xx * 2 + 1) + (yy * 2 + 1) * width;
				dst[xx + yy * newWidth] = Color32.Lerp(Color32.Lerp(src1[BLidx],src1[BRidx],.5F),
				                                       Color32.Lerp(src1[TLidx],src1[TRidx],.5F),.5F);
			}
		}
		return dst;
	}
Пример #21
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            for (int i = 0; i < PaletteSize; i++)
            {
                float r = Random.value;
                float g = Random.value;
                float b = Random.value;
                _palette[i] = new Color32((byte)(r * 255.0f), (byte)(g * 255.0f), (byte)(b * 255.0f), (byte)(b * 255.0f));
            }
        }

        _time += Time.deltaTime;

        int index = 0;
        float d = _time;
        for (int j = 0; j < Height; j++)
        {
            for (int i = 0; i < Width; i++)
            {
                float x = Mathf.Sin(i * 0.1f + d) - Mathf.Cos(j * 0.02f + d * 4f) + Mathf.Cos((j+i+d) * 0.015f) - Mathf.Sin((j-i-d*2.421f) * 0.0311f);
                x /= (float)j / (float)(Height/2);
                float lumaf = Mathf.Abs(x);
                int luma = (int)(lumaf * PaletteSize) % PaletteSize;
                _pixels[index++] = _palette[luma];
            }
        }

        _texture.SetPixels32(_pixels);
        _texture.Apply(false, false);
    }
	public void Initialize (Mesh mesh, Material[] materials, Color32 color, bool additive, float speed, int sortingLayerID, int sortingOrder) {
		StopAllCoroutines();

		gameObject.SetActive(true);


		meshRenderer.sharedMaterials = materials;
		meshRenderer.sortingLayerID = sortingLayerID;
		meshRenderer.sortingOrder = sortingOrder;

		meshFilter.sharedMesh = (Mesh)Instantiate(mesh);

		colors = meshFilter.sharedMesh.colors32;

		if ((color.a + color.r + color.g + color.b) > 0) {
			for (int i = 0; i < colors.Length; i++) {
				colors[i] = color;
			}
		}

		fadeSpeed = speed;

		if (additive)
			StartCoroutine(FadeAdditive());
		else
			StartCoroutine(Fade());
	}
Пример #23
0
    public void fill4(int x, int y, Color32 oldColor, Color32 newColor)
    {
        ArrayList stack = new ArrayList();

        stack.Add(new Vec2i(x,y));

        int emergency = 10000;

        while(stack.Count > 0 && emergency >= 0) {

            Vec2i pixel = (Vec2i)stack[stack.Count - 1];
            stack.RemoveAt(stack.Count - 1);

            if(canvas.GetPixel(pixel.x, pixel.y) == oldColor) {

                canvas.SetPixel(pixel.x, pixel.y, newColor);

                if(pixel.x + 1 < 96 && canvas.GetPixel(pixel.x + 1, pixel.y) == oldColor)
                    stack.Add(new Vec2i(pixel.x + 1, pixel.y));

                if(pixel.x - 1 >= 0 && canvas.GetPixel(pixel.x - 1, pixel.y) == oldColor)
                    stack.Add(new Vec2i(pixel.x - 1, pixel.y));

                if(pixel.y + 1 < 64 && canvas.GetPixel(pixel.x, pixel.y + 1) == oldColor)
                    stack.Add(new Vec2i(pixel.x, pixel.y + 1));

                if(pixel.y - 1 >= 0 && canvas.GetPixel(pixel.x, pixel.y - 1) == oldColor)
                    stack.Add(new Vec2i(pixel.x, pixel.y - 1));

            }

            emergency--;

        }
    }
    void NoiseTexture(int size, bool mono)
    {
        var path = EditorUtility.SaveFilePanel("Save Noise Texture", "Assets", "noise" + size, "png");
        if (path != "") {
            var tex = new Texture2D(size, size, TextureFormat.ARGB32, false);
            var s2 = size * size;
            var cols = new Color32[s2];
            for (int i = 0; i < s2; ++i) {
                if (mono) {
                    var r = (byte)Random.Range(0, 256);
                    cols[i] = new Color32(r, r, r, 255);
                }
                else {
                    cols[i] = new Color32((byte)Random.Range(0, 256), (byte)Random.Range(0, 256), (byte)Random.Range(0, 256), 255);
                }
            }
            tex.SetPixels32(cols);
            tex.Apply();
            System.IO.File.WriteAllBytes(path, tex.EncodeToPNG());
            AssetDatabase.Refresh();
            Object.DestroyImmediate(tex);
            path = "Assets" + path.Remove(0, Application.dataPath.Length);
            // tex = (Texture2D)AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D));

            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            textureImporter.textureFormat = TextureImporterFormat.ARGB32;
            textureImporter.anisoLevel = 0;
            AssetDatabase.ImportAsset(path);

            // EditorUtility.CompressTexture(tex, TextureFormat.ARGB32, 0);
            //tex.format = TextureFormat.ARGB32;
        }
    }
Пример #25
0
 public mBlock(Color32 color)
 {
     this.r = color.r;
     this.g = color.g;
     this.b = color.b;
     solid = true;
 }
Пример #26
0
        public void SetShadeStrength(float lightShade, float darkShade)
        {
            shading = lightShade;
			lighterColor = CalculateShade (referenceColor, lightShade, ColorShade.Lighter);
			darkerColor = CalculateShade (referenceColor, darkShade, ColorShade.Darker);

        }
Пример #27
0
        public ShadedColor(UnityEngine.Color32 referenceColor, float shading)
        {
            this.referenceColor = referenceColor;
			lighterColor = CalculateShade (referenceColor, shading, ColorShade.Lighter);
			darkerColor = CalculateShade (referenceColor, shading, ColorShade.Darker);
            this.shading = shading;
        }
Пример #28
0
        public static HSVColor rgbToHsv(Color32 color)
        {
            HSVColor result=new HSVColor();
            float min,max,delta;
            float r = (float)color.r/255.0f;
            float g = (float)color.g/255.0f;
            float b = (float)color.b/255.0f;

            min = Mathf.Min(r,g,b);
            max = Mathf.Max(r,g,b);
            result.v = max;
            delta = max - min;

            if( max != 0 )
                result.s = delta / max;		// s
            else {
                // r = g = b = 0		// s = 0, v is undefined
                result.s = 0;
                result.h = -1;
                return result;
            }
            if( r == max )
                result.h = ( g - b ) / delta;		// between yellow & magenta
            else if( g == max )
                result.h = 2 + ( b - r ) / delta;	// between cyan & yellow
            else
                result.h = 4 + ( r - g ) / delta;	// between magenta & cyan
            result.h *= 60;				// degrees
            if( result.h < 0 )
                result.h += 360;
            result.h /=360;
            return result;
        }
Пример #29
0
		//TODO probably can delete it
		public Slot (string bone, string slot, string attachment = null, Color32? color = null)
		{
			this.bone = bone;
			this.name = slot;
			this.defaultAttachmentName = attachment;
			this.color = color;
		}
    public SetPaletteColorCommand(Color32 color, int index)
    {
        _name = "SetPaletteColorCommand";

        _color = color;
        _index = index;
    }
		/// <summary>Lerps from one colour to another.</summary>
		private static Color32 ColorLerpUnclamped(Color32 c1,Color32 c2,float value){
			return new Color32 ((byte)(c1.r + (c2.r - c1.r)*value), 
								(byte)(c1.g + (c2.g - c1.g)*value), 
								(byte)(c1.b + (c2.b - c1.b)*value), 
								(byte)(c1.a + (c2.a - c1.a)*value)
								);
		}
    static int ToString(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                UnityEngine.Color32 obj = (UnityEngine.Color32)ToLua.CheckObject(L, 1, typeof(UnityEngine.Color32));
                string o = obj.ToString();
                LuaDLL.lua_pushstring(L, o);
                return(1);
            }
            else if (count == 2)
            {
                UnityEngine.Color32 obj = (UnityEngine.Color32)ToLua.CheckObject(L, 1, typeof(UnityEngine.Color32));
                string arg0             = ToLua.CheckString(L, 2);
                string o = obj.ToString(arg0);
                LuaDLL.lua_pushstring(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Color32.ToString"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #33
0
 /// <summary>
 /// Creates a 1x1 texture
 /// </summary>
 /// <param name="Background">Color of the texture</param>
 /// <returns></returns>
 internal static Texture2D CreateColorPixel(Color32 Background)
 {
     Texture2D retTex = new Texture2D(1, 1);
     retTex.SetPixel(0, 0, Background);
     retTex.Apply();
     return retTex;
 }
Пример #34
0
        public Level(Dictionary<string, string> textureLocations, int mapLength)
        {
            this.textures = loadTextures(textureLocations);
            bubbles = new List<Bubble>();
            platforms = new List<Platform>();

            Vector3 scaleMultiplier = new Vector3(7500, 100, 1);
            floor = new Floor(mapLength, textures["floorTexture"], scaleMultiplier);

            Vector3[] upperVertices = floor.getUpperVertices();
            List<Vector3> floorBubblePositions = new List<Vector3>();

            for (int i = 0; i < upperVertices.Length; i+=5)
            {
                Vector3 pos = new Vector3(upperVertices[i].x * scaleMultiplier.x, upperVertices[i].y * scaleMultiplier.y, upperVertices[i].z * scaleMultiplier.z);
                //floorBubblePositions.Add(upperVertices[i]);
                floorBubblePositions.Add(pos);
            }

            int bubbleHeightFromGround = 1;
            bubbleAverageColor = averageColorFromTexture(textures["bubbleTexture"]);
            createGroundBubbles(floorBubblePositions.ToArray(), bubbleHeightFromGround, textures["bubbleTexture"]);

            List<Vector3> platformPositions = generatePlatformPositions(scaleMultiplier);
            float platformMinimumHeight = 2.5f;
            createPlatforms(platformPositions.ToArray(), platformMinimumHeight, textures["platformTexture"]);

            //createGrass(floor.getUpperVertices()[0]);
        }
Пример #35
0
 public UnityEngine.Color32 SerializeIn_color32()
 {
     UnityEngine.Color32 c = new UnityEngine.Color32();
     c.r = SerializeIn_byte();
     c.g = SerializeIn_byte();
     c.b = SerializeIn_byte();
     c.a = SerializeIn_byte();
     return(c);
 }
Пример #36
0
 public void Serialize(ref UnityEngine.Color32 c)
 {
     if (m_writing)
     {
         SerializeOut_color32(c);
     }
     else
     {
         c = SerializeIn_color32();
     }
 }
Пример #37
0
 public static UnityEngine.Color ConvertColor(MazeWorld.Color color)
 {
     if (colorMap.ContainsKey(color))
     {
         return(colorMap[color]);
     }
     else
     {
         var c = new UnityEngine.Color32((byte)color.R, (byte)color.G, (byte)color.B, 255);
         colorMap.Add(color, c);
         return(c);
     }
 }
Пример #38
0
 static public int ctor_s(IntPtr l)
 {
     try {
         UnityEngine.Color32 o;
         o = new UnityEngine.Color32();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #39
0
 static public int op_Implicit__Color32__Color_s(IntPtr l)
 {
     try {
         UnityEngine.Color a1;
         checkType(l, 1, out a1);
         UnityEngine.Color32 ret = a1;
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #40
0
 static int HexColor32(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         uint arg0             = (uint)LuaDLL.luaL_checknumber(L, 1);
         UnityEngine.Color32 o = Utils.HexColor32(arg0);
         ToLua.PushValue(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #41
0
 static void Color32_b(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Color32 _this = (UnityEngine.Color32)vc.csObj;
         var result = _this.b;
         JSApi.setByte((int)JSApi.SetType.Rval, (System.Byte)(result));
     }
     else
     {
         System.Byte         arg0  = (System.Byte)JSApi.getByte((int)JSApi.GetType.Arg);
         UnityEngine.Color32 _this = (UnityEngine.Color32)vc.csObj;
         _this.b = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
 static void Particle_color(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.ParticleSystem.Particle _this = (UnityEngine.ParticleSystem.Particle)vc.csObj;
         var result = _this.color;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Color32 arg0 = (UnityEngine.Color32)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.ParticleSystem.Particle _this = (UnityEngine.ParticleSystem.Particle)vc.csObj;
         _this.color = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Пример #43
0
    static bool ParticleSystem_Emit__Vector3__Vector3__Single__Single__Color32(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 5)
        {
            UnityEngine.Vector3 arg0 = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
            UnityEngine.Vector3 arg1 = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
            System.Single       arg2 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            System.Single       arg3 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            UnityEngine.Color32 arg4 = (UnityEngine.Color32)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            ((UnityEngine.ParticleSystem)vc.csObj).Emit(arg0, arg1, arg2, arg3, arg4);
        }

        return(true);
    }
Пример #44
0
        public static ColorB Add(this ColorB color, byte value)
        {
#if OnUnity
            return(new ColorB(
                       (byte)(Mathf.Clamp((int)color.r + value, 0, 255)),
                       (byte)(Mathf.Clamp((int)color.g + value, 0, 255)),
                       (byte)(Mathf.Clamp((int)color.b + value, 0, 255)),
                       color.a));
#else
            return(ColorB.FromArgb(
                       color.A,
                       (byte)(Mathf.Clamp((int)color.R + value, 0, 255)),
                       (byte)(Mathf.Clamp((int)color.G + value, 0, 255)),
                       (byte)(Mathf.Clamp((int)color.B + value, 0, 255))));
#endif
        }
Пример #45
0
 static int LerpUnclamped(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UnityEngine.Color32 arg0 = (UnityEngine.Color32)ToLua.CheckObject(L, 1, typeof(UnityEngine.Color32));
         UnityEngine.Color32 arg1 = (UnityEngine.Color32)ToLua.CheckObject(L, 2, typeof(UnityEngine.Color32));
         float arg2            = (float)LuaDLL.luaL_checknumber(L, 3);
         UnityEngine.Color32 o = UnityEngine.Color32.LerpUnclamped(arg0, arg1, arg2);
         ToLua.PushValue(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_a(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Color32 obj = (UnityEngine.Color32)o;
            byte ret = obj.a;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index a on a nil value"));
        }
    }
Пример #47
0
    static int set_bottomColor(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIGradient          obj  = (UIGradient)o;
            UnityEngine.Color32 arg0 = (UnityEngine.Color32)ToLua.CheckObject(L, 2, typeof(UnityEngine.Color32));
            obj.bottomColor = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index bottomColor on a nil value" : e.Message));
        }
    }
Пример #48
0
    static int get_outLineColor(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            YlyRichText         obj = (YlyRichText)o;
            UnityEngine.Color32 ret = obj.outLineColor;
            ToLua.PushValue(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index outLineColor on a nil value" : e.Message));
        }
    }
Пример #49
0
    static int get_bottomColor(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIGradient          obj = (UIGradient)o;
            UnityEngine.Color32 ret = obj.bottomColor;
            ToLua.PushValue(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index bottomColor on a nil value" : e.Message));
        }
    }
    static int set_a(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Color32 obj = (UnityEngine.Color32)o;
            byte arg0 = (byte)LuaDLL.luaL_checknumber(L, 2);
            obj.a = arg0;
            ToLua.SetBack(L, 1, obj);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index a on a nil value"));
        }
    }
Пример #51
0
        public static ColorB Add(this ColorB color, float value)
        {
            byte byteValue = (byte)(value * 255f);

#if OnUnity
            return(new ColorB(
                       (byte)(Mathf.Clamp((int)color.r + byteValue, 0, 255)),
                       (byte)(Mathf.Clamp((int)color.g + byteValue, 0, 255)),
                       (byte)(Mathf.Clamp((int)color.b + byteValue, 0, 255)),
                       color.a));
#else
            return(ColorB.FromArgb(
                       color.A,
                       (byte)(Mathf.Clamp((int)color.R + byteValue, 0, 255)),
                       (byte)(Mathf.Clamp((int)color.G + byteValue, 0, 255)),
                       (byte)(Mathf.Clamp((int)color.B + byteValue, 0, 255))));
#endif
        }
Пример #52
0
 static public int Lerp_s(IntPtr l)
 {
     try{
         UnityEngine.Color32 a1;
         checkType(l, 1, out a1);
         UnityEngine.Color32 a2;
         checkType(l, 2, out a2);
         System.Single a3;
         checkType(l, 3, out a3);
         UnityEngine.Color32 ret = UnityEngine.Color32.Lerp(a1, a2, a3);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Пример #53
0
    static int Emit(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <UnityEngine.ParticleSystem.Particle>(L, 2))
            {
                UnityEngine.ParticleSystem          obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle arg0 = StackTraits <UnityEngine.ParticleSystem.Particle> .To(L, 2);

                obj.Emit(arg0);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes <int>(L, 2))
            {
                UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                obj.Emit(arg0);
                return(0);
            }
            else if (count == 6)
            {
                UnityEngine.ParticleSystem obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.Vector3        arg0 = ToLua.ToVector3(L, 2);
                UnityEngine.Vector3        arg1 = ToLua.ToVector3(L, 3);
                float arg2 = (float)LuaDLL.luaL_checknumber(L, 4);
                float arg3 = (float)LuaDLL.luaL_checknumber(L, 5);
                UnityEngine.Color32 arg4 = StackTraits <UnityEngine.Color32> .Check(L, 6);

                obj.Emit(arg0, arg1, arg2, arg3, arg4);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.Emit"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int Lerp(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 3);
            UnityEngine.Color32 arg0 = StackTraits <UnityEngine.Color32> .Check(L, 1);

            UnityEngine.Color32 arg1 = StackTraits <UnityEngine.Color32> .Check(L, 2);

            float arg2            = (float)LuaDLL.luaL_checknumber(L, 3);
            UnityEngine.Color32 o = UnityEngine.Color32.Lerp(arg0, arg1, arg2);
            ToLua.PushValue(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #55
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Color32 o;
         System.Byte         a1;
         checkType(l, 2, out a1);
         System.Byte a2;
         checkType(l, 3, out a2);
         System.Byte a3;
         checkType(l, 4, out a3);
         System.Byte a4;
         checkType(l, 5, out a4);
         o = new UnityEngine.Color32(a1, a2, a3, a4);
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #56
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.Color32 o;
     if (matchType(l, 1, typeof(System.Byte), typeof(System.Byte), typeof(System.Byte), typeof(System.Byte)))
     {
         System.Byte a1;
         checkType(l, 1, out a1);
         System.Byte a2;
         checkType(l, 2, out a2);
         System.Byte a3;
         checkType(l, 3, out a3);
         System.Byte a4;
         checkType(l, 4, out a4);
         o = new UnityEngine.Color32(a1, a2, a3, a4);
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Color32 o;
         System.Byte         a1;
         checkType(l, 2, out a1);
         System.Byte a2;
         checkType(l, 3, out a2);
         System.Byte a3;
         checkType(l, 4, out a3);
         System.Byte a4;
         checkType(l, 5, out a4);
         o = new UnityEngine.Color32(a1, a2, a3, a4);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Пример #58
0
    public static Texture2D ToTexture2D(this Bitmap bitmap, Texture2D texture)
    {
        if (texture == null)
        {
            texture = new Texture2D(bitmap.Width, bitmap.Height, bitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb ? TextureFormat.ARGB32 : TextureFormat.RGB24, false);
        }
        else if (texture.width != bitmap.Width || texture.height != bitmap.Height)
        {
            texture.Resize(bitmap.Width, bitmap.Height);
        }

        UnityEngine.Color32[] colors = new UnityEngine.Color32[texture.width * texture.height];

        var data      = bitmap.LockBits(new Rectangle(Point.Empty, bitmap.Size), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        var pixelSize = data.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb ? 4 : 3;
        var padding   = data.Stride - (data.Width * pixelSize);

        unsafe
        {
            byte *ptr = (byte *)data.Scan0.ToPointer();

            var index = 0;
            for (var y = 0; y < data.Height; y++)
            {
                for (var x = 0; x < data.Width; x++)
                {
                    colors[x + (data.Height - 1 - y) * data.Width] = new Color32(*(ptr + index + 2), *(ptr + index + 1), *(ptr + index + 0), (byte)(*(ptr + index + 3) * 1f));
                    index += pixelSize;
                }
                index += padding;
            }
        }
        bitmap.UnlockBits(data);

        texture.SetPixels32(colors);
        texture.Apply();
        return(texture);
    }
Пример #59
0
    static bool Texture2D_SetPixels32__Color32_Array(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.Color32[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.Color32[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new UnityEngine.Color32[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (UnityEngine.Color32)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            ((UnityEngine.Texture2D)vc.csObj).SetPixels32(arg0);
        }

        return(true);
    }
Пример #60
0
 public ColorRGBA(UnityEngine.Color32 c) : this(c.r, c.g, c.b, c.a)
 {
 }