SetPixels() private method

private SetPixels ( Color colors ) : void
colors Color
return void
コード例 #1
0
    public void CalculateWidget()
    {
        int canvasWidth = FullHeart.width * (_playerHealthSystem.MaxHP / 2);
        int fullHearts = _playerHealthSystem.HP / 2;
        int halfHearts = _playerHealthSystem.HP % 2;
        int deadHearts = (_playerHealthSystem.MaxHP / 2) - (_playerHealthSystem.HP / 2);

        Texture2D tex = new Texture2D(canvasWidth, FullHeart.height);

        int i = 0;

        for(int counter = 0; counter < fullHearts; counter++)
        {
            tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, FullHeart.GetPixels());
            i += FullHeart.width;
        }

        for(int counter = 0; counter < halfHearts; counter++)
        {
            tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, HalfHeart.GetPixels());
            i += FullHeart.width;
        }

        for(int counter = 0; counter < deadHearts; counter++)
        {
            tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, NoHeart.GetPixels());
            i += FullHeart.width;
        }

        tex.Apply();

        _fullUiWidget = tex;
        UiWidget.Image = _fullUiWidget;
    }
コード例 #2
0
    private void UpdateFogTexture(GameObject[] visions)
    {
        var texture = new Texture2D(128, 128);

        var fog = fogTexture.GetPixels(0, 0, 128, 128);

        texture.SetPixels(fog);
        var texturePixels = texture.GetPixels();

        for (int i = 0; i < visions.Length; i++)
        {
            var visionPos = visions[i].transform.position;
            var texturePos = new Vector2(visionPos.x, visionPos.z);
            texturePos += mapOffset;
            texturePos /= mapSize;
            texturePos *= fogSize;
            texturePos -= new Vector2(16, 16);
            int x = Mathf.FloorToInt(texturePos.x);
            int y = Mathf.FloorToInt(texturePos.y);
            AddPixels(texturePixels, visionPixels, x, y, GetVisionPoly(visions[i].transform.position));
        }
        texture.SetPixels(texturePixels);

        texture.Apply();

        Shader.SetGlobalTexture("_FogTex", texture);
        Shader.SetGlobalTexture("_LastFogTex", lastFogTexture);
        Shader.SetGlobalFloat("_FogBlend", 0f);

        lastFogTexture = texture;
    }
コード例 #3
0
ファイル: BackgroundMaker.cs プロジェクト: attrition/ROGUESPY
    Texture2D InitMapTexture()
    {
        // texture colors
        var texCols = MapTexture.GetPixels();
        var height = MapTexture.height;
        var width = MapTexture.width;

        // find next largest power of 2 from width
        int pot = 1;
        while (pot < width)
            pot <<= 1;

        // fill texture
        var blacks = new Color[pot * pot];
        for (int i = 0; i < pot * pot; i++)
            blacks[i] = Color.black;

        var bgTex = new Texture2D(pot, pot, TextureFormat.RGBA32, false); // must be power of 2
        bgTex.filterMode = FilterMode.Point;
        bgTex.wrapMode = TextureWrapMode.Clamp;
        bgTex.SetPixels(blacks);
        bgTex.SetPixels(0, 0, width, height, texCols);
        bgTex.Apply();

        // set material texture
        var rend = BGObj.GetComponent<MeshRenderer>();
        rend.material.SetTexture("_MainTex", bgTex);

        return bgTex;
    }
コード例 #4
0
    public void Generate2DTexture()
    {
        texture2D = new Texture2D(n,n,TextureFormat.ARGB32,true);
        int size = n*n;
        Color[] cols = new Color[size];
        float u,v;
        int idx = 0;
        Color c = Color.white;
        for(int i = 0; i < n; i++) {
            u = i/(float)n;
            for(int j = 0; j < n; j++, ++idx) {
              	v = j/(float)n;
                float noise = Mathf.PerlinNoise(u,v);
                c.r = c.g = c.b = noise;
                cols[idx] = c;

            }
        }

        texture2D.SetPixels(cols);
        texture2D.Apply();
        renderer.material.SetTexture("g_tex", texture2D);

        //Color[] cs = texture3D.GetPixels();
        //for(int i = 0; i < 10; i++)
        //	Debug.Log (cs[i]);
    }
コード例 #5
0
ファイル: ImageLibrary.cs プロジェクト: devNaroo/2DWalker
	public static void GetSpriteAndTextureData() {
		Object[] spriteImageFromDataPath = Resources.LoadAll(@"[Graphics]/SourceFiles/Tilesheets", typeof(Sprite));
        
		if (spriteImageFromDataPath == null) {
			return;
		}
        
		foreach (Object sprite in spriteImageFromDataPath) {
			Sprite s = (Sprite)sprite;
			spriteImages.Add(s);
		}
				
		for (int i = 0; i < spriteImages.Count; i++) {
			spriteDictionary.Add(i, spriteImages [i]);
		}
				
		foreach (Sprite sprite in spriteImageFromDataPath) {
			Texture2D croppedTexture = new Texture2D((int)sprite.rect.width, (int)sprite.rect.height);
			var pixels = sprite.texture.GetPixels((int)sprite.textureRect.x,
			                                      (int)sprite.textureRect.y,
			                                      (int)sprite.textureRect.width,
			                                      (int)sprite.textureRect.height);
			
			croppedTexture.SetPixels(pixels);
			croppedTexture.name = sprite.name;
			croppedTexture.Apply();
			textureImages.Add(croppedTexture);
		}
	}
コード例 #6
0
    public static Texture2D CalculateNormalMap(Texture2D source, float strength)
    {
        Texture2D result;
        float xLeft, xRight;
        float yUp, yDown;
        float yDelta, xDelta;
        var pixels = new Color[source.width * source.height];
        strength = Mathf.Clamp(strength, 0.0F, 10.0F);        
        result = new Texture2D(source.width, source.height, TextureFormat.ARGB32, true);
        
        for (int by = 0; by < result.height; by++)
        {
            for (int bx = 0; bx < result.width; bx++)
            {
                xLeft = source.GetPixel(bx - 1, by).grayscale * strength;
                xRight = source.GetPixel(bx + 1, by).grayscale * strength;
                yUp = source.GetPixel(bx, by - 1).grayscale * strength;
                yDown = source.GetPixel(bx, by + 1).grayscale * strength;
                xDelta = ((xLeft - xRight) + 1) * 0.5f;
                yDelta = ((yUp - yDown) + 1) * 0.5f;

                pixels[bx + by * source.width] = new Color(xDelta, yDelta, 1.0f, yDelta);
            }
        }

        result.SetPixels(pixels);
        result.wrapMode = TextureWrapMode.Clamp;
        result.Apply();
        return result;
    }
コード例 #7
0
    public IEnumerator GetAd(int id)
    {
		BusinessCard = null;
        adReady = false;
        hasAd = false;
        BusinessID = id;
        string adURL = serverURL + "getAd?b=" + id;
        string bcURL = serverURL + "bizcard?id=" + id;

        WWW card = new WWW(bcURL);
        yield return card;
        BusinessCard = new Texture2D(Convert.ToInt32(card.texture.width),
                              Convert.ToInt32(card.texture.height),
                              TextureFormat.ARGB32, false);
        BusinessCard.SetPixels(card.texture.GetPixels());
        BusinessCard.Apply();

        WWW page = new WWW(adURL);
        yield return page;
        if (page.error == null && page.text[0] == '{')
        {
            Debug.Log(page.text);
            // Get the ad as a Dictionary object.
            hasAd = true;
            Dictionary<string, object> ad = Json.Deserialize(page.text) as Dictionary<string, object>;
            AdImages(ad);
            AdInfo = new AdData(ad);
        }

        adReady = true;
    }
コード例 #8
0
        private Texture2D DownSample(Texture2D src)
        {
            int width = 1024, height = 512;
            Texture2D dst = new Texture2D(width, height, TextureFormat.ARGB32, false);
            Color[] cs = new Color[width * height];
            for (int x = 0; x < width; ++x)
            for (int y = 0; y < height; ++y) {
                int dstIndex = x + y * width;
                Color dstColor = Color.black;

                for (int subX = 0; subX < 4; ++subX)
                    for (int subY = 0; subY < 4; ++subY) {
                        Color srcColor = src.GetPixel(x * 4 + subX, y * 4 + subY);
                        dstColor += srcColor;
                    }

                dstColor /= 16.0f;
                dstColor.a = 1.0f;

                cs[dstIndex] = dstColor;
            }
            dst.SetPixels(cs);
            dst.Apply();

            return dst;
        }
コード例 #9
0
ファイル: MapTexture2.cs プロジェクト: WilliamChao/nmap
        public void ShowElevation(GameObject plane, Map2 map)
        {
            var textureWidth = (int)Map1.Width * _textureScale;
            var textureHeight = (int)Map1.Height * _textureScale;

            var texture = new Texture2D(textureWidth, textureHeight, TextureFormat.RGB565, true);
            texture.SetPixels(Enumerable.Repeat(BiomeProperties.Colors[Biome.Ocean], textureWidth * textureHeight).ToArray());

            //绘制陆地
            var lands = map.Graph.centers.Where(p => !p.ocean);
            foreach (var land in lands)
                texture.FillPolygon(
                    land.corners.Select(p => p.point * _textureScale).ToArray(),
					BiomeProperties.Colors[Biome.Beach] * land.elevation);

            //绘制边缘
            var lines = map.Graph.edges.Where(p => p.v0 != null).Select(p => new[]
            {
                p.v0.point.x, p.v0.point.y,
                p.v1.point.x, p.v1.point.y
            }).ToArray();

            foreach (var line in lines)
                DrawLine(texture, line[0], line[1], line[2], line[3], Color.black);
            //绘制中心点
            var points = map.Graph.centers.Select(p => p.point).ToList();
            foreach (var p in points)
                texture.SetPixel((int)(p.x * _textureScale), (int)(p.y * _textureScale), Color.red);

            texture.Apply();

            plane.GetComponent<Renderer>().material.mainTexture = texture;
        }
コード例 #10
0
    /// <summary>
    /// Converts vector data stored within a texture using the specified basis.  Assume all calculations are performed in tangent space.
    /// </summary>
    /// <param name='basis'>
    /// Basis to multiply the vector values against.
    /// </param>
    /// <param name='vectorData'>
    /// Texture2D containing vector data.  Textures are passed by reference, so make sure to copy beforehand if you don't want to overwrite your data!
    /// </param>
    public static void ConvertTangentBasis(Matrix4x4 basis, ref Texture2D vectorData, bool recomputeZ = false)
    {
        Color[] colorData = vectorData.GetPixels();
        Texture2D tmpTexture = new Texture2D(vectorData.width, vectorData.height, TextureFormat.ARGB32, false);

        for (int i = 0; i < colorData.Length; i++)
        {
            Color vecData = new Color(colorData[i].r, colorData[i].g, colorData[i].b, 1);
            vecData.r = Vector3.Dot(new Vector3(basis.m00, basis.m01, basis.m02), UnpackUnitVector(new Vector3(colorData[i].r, colorData[i].g, colorData[i].b))) * 0.5f + 0.5f;
            vecData.g = Vector3.Dot(new Vector3(basis.m10, basis.m11, basis.m12), UnpackUnitVector(new Vector3(colorData[i].r, colorData[i].g, colorData[i].b))) * 0.5f + 0.5f;
            if (recomputeZ)
            {
                vecData.r = vecData.r * 2 - 1;
                vecData.g = vecData.g * 2 - 1;
                vecData.b = Mathf.Sqrt(1 - vecData.r * vecData.r - vecData.g * vecData.g) * 0.5f + 0.5f;
                vecData.r = vecData.r * 0.5f + 0.5f;
                vecData.g = vecData.g * 0.5f + 0.5f;
            } else {
                vecData.b = Vector3.Dot(new Vector3(basis.m20, basis.m21, basis.m22), UnpackUnitVector(new Vector3(colorData[i].r, colorData[i].g, colorData[i].b))) * 0.5f + 0.5f;
            }
            colorData[i] = vecData;
        }
        tmpTexture.SetPixels(colorData);
        tmpTexture.Apply();
        vectorData = tmpTexture;
    }
コード例 #11
0
ファイル: MisGunGenerator.cs プロジェクト: lucasnfe/Metronome
	public static MisGun GenerateGun(GameObject owner) {

		// Set a random frequency
		float frequency = Random.Range(1f, 2f);

		// Set a random speed
		float speed = 60f/frequency;

		// Set a random damage
		int damage = (int)(10f/frequency);

		int size = Random.Range (4, 8);

		// Create a newtexture
		Texture2D texture = new Texture2D(size, size, TextureFormat.ARGB32, false);

		Color []bulletColors = new Color[size * size];
		for(int i = 0; i < bulletColors.Length; i++)
			bulletColors[i] = Color.grey;

		texture.SetPixels (bulletColors);

		// Apply all SetPixel calls
		texture.Apply();

		MisGun gun = new MisGun (damage, speed, frequency, texture, owner);

		return gun;
	}
コード例 #12
0
ファイル: MuhShader.cs プロジェクト: AVUIs/un1c0rn3r
    void Start()
    {
        Renderer rend = GetComponent<Renderer>();

        // duplicate the original texture and assign to the material
        tex = Instantiate(rend.material.mainTexture) as Texture2D;
        tex.Resize (200, 100);
        rend.material.mainTexture = tex;

        // colors used to tint the first 3 mip levels
        Color[] colors = new Color[3];
        colors[0] = Color.red;
        colors[1] = Color.green;
        colors[2] = Color.blue;
         mipCount = Mathf.Min(3, tex.mipmapCount);

        // tint each mip level
        for( var mip = 0; mip < mipCount; ++mip ) {
            var cols = tex.GetPixels( mip );
            for( var i = 0; i < cols.Length; ++i ) {
                cols[i] = new Color(Random.value,Random.value,Random.value);
            }
            tex.SetPixels( cols, mip );
        }
        // actually apply all SetPixels, don't recalculate mip levels
        tex.Apply(false);
        int length = tex.GetPixels ().Length;
        wat = new float[length];
        for (int i =0; i< wat.Length; i++)
            wat [i] = Random.value;
        Debug.Log ("n minmaps: " + mipCount);

        //for(int i =0; i< wa
    }
コード例 #13
0
	void OnEnable()
	{
		pb_Object[] pbs = (pb_Object[])Selection.transforms.GetComponents<pb_Object>();

		if(pbs.Length == 2)
		{
			lhs = pbs[0].gameObject;
			rhs = pbs[1].gameObject;
		}

		previewBackground = new GUIStyle();
		
		backgroundTexture = new Texture2D(2,2);

		backgroundTexture.SetPixels(new Color[] {
			backgroundColor,
			backgroundColor, 
			backgroundColor, 
			backgroundColor });

		backgroundTexture.Apply();

		previewBackground.normal.background = backgroundTexture;

		unicodeIconStyle = new GUIStyle();
		unicodeIconStyle.fontSize = 64;
		unicodeIconStyle.normal.textColor = Color.white;
		unicodeIconStyle.alignment = TextAnchor.MiddleCenter;
	}
コード例 #14
0
    private void Awake()
    {
        var rectTransform = GetComponent<RectTransform>();
        var textureWidth = (int) rectTransform.rect.width;
        var textureHeight = (int) rectTransform.rect.height;

        var gradient = GameManager.Instance.StateColorDisplayRange;

        var stepCount = Settings.Instance.Amplitude * 2 + 1;

        texture = new Texture2D(textureWidth, textureHeight, TextureFormat.ARGB32, false, false);
        var colors = new Color[textureWidth * textureHeight];
        for (var x = 0; x < textureWidth; x++)
        {
            //var color = gradient.Evaluate(Mathf.Clamp((float) x / (textureWidth - 1), cutoffValues.From, cutoffValues.To));
            var t = (float) x / textureWidth;
            var color = gradient.Evaluate((Mathf.FloorToInt(t * stepCount) + 0.5f) / stepCount);
            for (var y = 0; y < textureHeight; y++)
            {
                colors[x + y * textureWidth] = color;
            }
        }

        texture.SetPixels(colors);
        texture.Apply();

        imageDisplay = GetComponent<RawImage>();
        imageDisplay.texture = texture;
    }
コード例 #15
0
 public static void Encode(Texture2D src, Texture2D dst, bool gpu = false,
                           YCgACoFormat format = YCgACoFormat.CgACoY_DontChange,
                           int quality = 100)
 {
     var pixels = src.GetPixels();
     Resize(src, dst, format);
     var resized = src.width != dst.width || src.height != dst.height;
     if (gpu)
     {
         // TODO: Force mipmap and trilinear when resized.
         var shader = Shader.Find("Hidden/RGBA to CgACoY");
         var mat = new Material(shader);
         var temp = RenderTexture.GetTemporary(dst.width, dst.height);
         Graphics.Blit(src, temp, mat);
         dst.ReadPixels(new Rect(0, 0, dst.width, dst.height), 0, 0);
         RenderTexture.ReleaseTemporary(temp);
         Object.DestroyImmediate(mat);
     }
     else
     {
         if (resized)
         {
             var srcPixels = pixels;
             pixels = dst.GetPixels();
             Shrink(srcPixels, pixels, src.width, dst.width);
         }
         RGBAToCgACoY(pixels, pixels);
         dst.SetPixels(pixels);
     }
     Compress(dst, format, quality);
 }
コード例 #16
0
		public static void CreateSubMips(Cubemap cube) {
			AssetDatabase.StartAssetEditing();
			int faceSize = cube.width;
			string cubePath = AssetDatabase.GetAssetPath(cube);

			//load all sub-assets
			UnityEngine.Object[] mips = AssetDatabase.LoadAllAssetRepresentationsAtPath(cubePath);
			if(mips != null) {
				for(int i=0; i<mips.Length; ++i) {
					if( mips[i] != null && AssetDatabase.IsSubAsset(mips[i]) ) UnityEngine.Object.DestroyImmediate(mips[i], true);
				}
			}
			AssetDatabase.Refresh();

			// skip mip level 0, its in the cubemap itself
			faceSize = faceSize >> 1;
			for( int mip = 1; faceSize > 0; ++mip ) {
				// extract mipmap faces from a cubemap and add them as textures in the sub image
				Texture2D tex = new Texture2D(faceSize, faceSize*6,TextureFormat.ARGB32,false);
				tex.name = "mip"+mip;
				for( int face = 0; face<6; ++face ) {
					tex.SetPixels(0, face*faceSize, faceSize, faceSize, cube.GetPixels((CubemapFace)face,mip));
				}
				tex.Apply();
				AssetDatabase.AddObjectToAsset(tex, cubePath);
				AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(tex));
				faceSize = faceSize >> 1;
			}
			AssetDatabase.StopAssetEditing();
			AssetDatabase.Refresh();
		}
コード例 #17
0
ファイル: UIColorPicker.cs プロジェクト: ChungH/BNG
	void Start ()
	{
		mTrans = transform;
		mUITex = GetComponent<UITexture>();
		mCam = UICamera.FindCameraForLayer(gameObject.layer);

		mWidth = mUITex.width;
		mHeight = mUITex.height;
		Color[] cols = new Color[mWidth * mHeight];

		for (int y = 0; y < mHeight; ++y)
		{
			float fy = (y - 1f) / mHeight;

			for (int x = 0; x < mWidth; ++x)
			{
				float fx = (x - 1f) / mWidth;
				int index = x + y * mWidth;
				cols[index] = Sample(fx, fy);
			}
		}

		mTex = new Texture2D(mWidth, mHeight, TextureFormat.RGB24, false);
		mTex.SetPixels(cols);
		mTex.filterMode = FilterMode.Trilinear;
		mTex.wrapMode = TextureWrapMode.Clamp;
		mTex.Apply();
		mUITex.mainTexture = mTex;

		Select(value);
	}
コード例 #18
0
ファイル: NgAtlas.cs プロジェクト: seonwifi/bongbong
    // ----------------------------------------------------------------------------------
    public static Texture2D CloneAtlasTexture(Texture tex)
    {
        string						texturePath		= AssetDatabase.GetAssetPath(tex);
        TextureImporter				importer		= (TextureImporter)TextureImporter.GetAtPath(texturePath);
        bool						bReadable		= importer.isReadable;
        int							maxTexSize		= importer.maxTextureSize;
        TextureImporterFormat		textureFormat	= importer.textureFormat;
        TextureImporterNPOTScale	npotScale 		= importer.npotScale;

        Texture2D		srcTex		= (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
        SetSourceTexture(srcTex);
        Texture2D		tarTex		= new Texture2D(srcTex.width, srcTex.height, TextureFormat.ARGB32, false);
        Color[] colBuf	= srcTex.GetPixels(0);
        tarTex.SetPixels(colBuf, 0);
        tarTex.Apply(false);

        // Restore
        importer.isReadable		= bReadable;
        importer.maxTextureSize	= maxTexSize;
        importer.textureFormat	= textureFormat;
        importer.npotScale		= npotScale;
        AssetDatabase.ImportAsset(texturePath, ImportAssetOptions.ForceSynchronousImport);

        return tarTex;
    }
コード例 #19
0
        /// <summary>
        /// Creates a new sprite using the size of the image inside the atlas.
        /// </summary>
        /// <param name="dimensions">The location and size of the sprite within the atlas (in pixels).</param>
        /// <param name="spriteName">The name of the sprite to create</param>
        /// <param name="atlasName">The name of the atlas to add the sprite to.</param>
        /// <returns></returns>
        public static bool AddSpriteToAtlas(Rect dimensions, string spriteName, string atlasName)
        {
            bool returnValue = false;

            if (m_atlasStore.ContainsKey(atlasName))
            {
                UITextureAtlas foundAtlas = m_atlasStore[atlasName];
                Texture2D atlasTexture = foundAtlas.texture;
                Vector2 atlasSize = new Vector2(atlasTexture.width, atlasTexture.height);
                Rect relativeLocation = new Rect(new Vector2(dimensions.position.x / atlasSize.x, dimensions.position.y / atlasSize.y), new Vector2(dimensions.width / atlasSize.x, dimensions.height / atlasSize.y));
                Texture2D spriteTexture = new Texture2D((int)Math.Round(dimensions.width), (int)Math.Round(dimensions.height));

                spriteTexture.SetPixels(atlasTexture.GetPixels((int)dimensions.position.x, (int)dimensions.position.y, (int)dimensions.width, (int)dimensions.height));

                UITextureAtlas.SpriteInfo createdSprite = new UITextureAtlas.SpriteInfo()
                {
                    name = spriteName,
                    region = relativeLocation,
                    texture = spriteTexture,
                    border = new RectOffset()
                };

                foundAtlas.AddSprite(createdSprite);
                returnValue = true;
            }

            return returnValue;
        }
コード例 #20
0
    void ExportAsImg(int devIdx)
    {
        // create a plane with prefab and assign img as texture
        // export data in current frame to image;
        Texture2D tex = new Texture2D(80, 48, TextureFormat.RGB24, false);

        Material mainMat = framePlanes[devIdx].GetComponent<Renderer> ().material;
        framePlanes[devIdx].GetComponent<Renderer>().enabled = true;
        Texture mainTex = mainMat.mainTexture;
        Debug.Log (mainTex.height);
        //		int w = mainTex.width;

        var colors = new Color[48 * 80];
        for (int i = 0; i < 48 * 80; i++) {
            colors [i].r = eachFrameImg[devIdx,i];
            colors [i].g = eachFrameImg[devIdx,i];
            colors [i].b = eachFrameImg[devIdx,i];
            //colors[i].a = 1.0f;
            //colors[i] = Color.green;
        }
        //tex.LoadImage (eachFrameImg);
        tex.SetPixels (colors);
        tex.Apply( true );
        framePlanes[devIdx].GetComponent<Renderer>().material.mainTexture = tex;
    }
コード例 #21
0
    public void DrawCurrentTiles()
    {
        for (int a = 0; a < currentTileList.Length; a++)
        {
            #region Obtain Tile GUI Sprite From Editor Sprite
            var b = currentTileList[a].transform.FindChild("Editor Sprite");
            if (b != null)
            {
                metaTileTex = b.gameObject.GetComponent<SpriteRenderer>().sprite;
                b.gameObject.SetActive(false);
            }
            else
            {
                metaTileTex = tileLostTex;
            }
            #endregion

            #region Create GUI Tile Texture
            Color[] pixels = metaTileTex.texture.GetPixels((int)metaTileTex.textureRect.x, (int)metaTileTex.textureRect.y, (int)metaTileTex.textureRect.width, (int)metaTileTex.textureRect.height); //Copys pixles of Sprite.
            Texture2D tileObjectTex = new Texture2D((int)metaTileTex.rect.width, (int)metaTileTex.rect.height); //Create a new Texture to set all of copied pixels to.
            tileObjectTex.filterMode = FilterMode.Point;
            tileObjectTex.SetPixels(pixels);
            tileObjectTex.Apply();
            GUIStyle styleTile = new GUIStyle();
            styleTile.normal.background = tileObjectTex; //Apply Texture to Style BG.
            styleTile.normal.background.name = currentTileList[a].name;
            TileListStyle[a] = styleTile; // Apply temp tile style to Public Main List Tile Style
            #endregion
        }
    }
コード例 #22
0
        public MiniMapSector(int x, int y, int z)
        {
            SectorX = x;
            SectorY = y;
            SectorZ = z;

            Texture2D = new Texture2D(Constants.MiniMapSectorSize, Constants.MiniMapSectorSize, TextureFormat.ARGB32, true)
            {
                filterMode = FilterMode.Point
            };

            Texture2D.SetPixels(Enumerable.Repeat(Color.black, Constants.MiniMapSectorSize * Constants.MiniMapSectorSize).ToArray());
            Texture2D.Apply();

            m_WaypointsTexture2D = new Texture2D(Constants.MiniMapSectorSize, Constants.MiniMapSectorSize, TextureFormat.ARGB32, true)
            {
                filterMode = FilterMode.Point
            };

            m_WaypointsTexture2D.SetPixels(Enumerable.Repeat(Colors.ColorFrom8Bit(Constants.PathCostUndefined), Constants.MiniMapSectorSize * Constants.MiniMapSectorSize).ToArray());
            m_WaypointsTexture2D.Apply();

            for (int i = 0; i < m_Cost.Length; i++)
            {
                m_Cost[i] = Constants.PathCostUndefined;
            }
        }
コード例 #23
0
ファイル: TextureHelper.cs プロジェクト: Bullshitzu/SGU
        public static Texture2D GreyscaleToNormal(Texture2D greyscale)
        {
            int width = greyscale.width;
            int height = greyscale.height;

            int lenght = width * height;

            Color[] pixelsNormal = new Color[lenght];

            for (int x = 0; x < width; x++) {
                for (int y = 0; y < height; y++) {

                    float currValue = greyscale.GetPixel(x, y).grayscale;

                    float x1n = greyscale.GetPixel(x - 1, y).grayscale;
                    float x1 = greyscale.GetPixel(x + 1, y).grayscale;
                    float y1n = greyscale.GetPixel(x, y - 1).grayscale;
                    float y1 = greyscale.GetPixel(x, y + 1).grayscale;

                    float normalXValue = (currValue - x1n) + (x1 - currValue) * 10 + 0.5f;
                    float normalYValue = (currValue - y1n) + (y1 - currValue) * 10 + 0.5f;

                    pixelsNormal[x + y * width] = new Color(1, 1-normalYValue, 1, 1-normalXValue);
                }
            }

            Texture2D normalmap = new Texture2D(width, height);
            normalmap.SetPixels(pixelsNormal);
            normalmap.Apply();
            return normalmap;
        }
コード例 #24
0
        void InitModules()
        {
            m_AllRegisteredModules = new List <SpriteEditorModuleBase>();
            m_ModuleRequireSpriteDataProvider.Clear();

            if (m_OutlineTexture == null)
            {
                m_OutlineTexture = new UnityTexture2D(1, 16, TextureFormat.RGBA32, false);
                m_OutlineTexture.SetPixels(new Color[]
                {
                    new Color(0.5f, 0.5f, 0.5f, 0.5f), new Color(0.5f, 0.5f, 0.5f, 0.5f), new Color(0.8f, 0.8f, 0.8f, 0.8f), new Color(0.8f, 0.8f, 0.8f, 0.8f),
                    Color.white, Color.white, Color.white, Color.white,
                    new Color(.8f, .8f, .8f, 1f), new Color(.5f, .5f, .5f, .8f), new Color(0.3f, 0.3f, 0.3f, 0.5f), new Color(0.3f, .3f, 0.3f, 0.5f),
                    new Color(0.3f, .3f, 0.3f, 0.3f), new Color(0.3f, .3f, 0.3f, 0.3f), new Color(0.1f, 0.1f, 0.1f, 0.1f), new Color(0.1f, .1f, 0.1f, 0.1f)
                });
                m_OutlineTexture.Apply();
                m_OutlineTexture.hideFlags = HideFlags.HideAndDontSave;
            }
            var outlineTexture = new Texture2DWrapper(m_OutlineTexture);

            // Add your modules here
            RegisterModule(new SpriteFrameModule(this, m_EventSystem, m_UndoSystem, m_AssetDatabase));
            RegisterModule(new SpritePolygonModeModule(this, m_EventSystem, m_UndoSystem, m_AssetDatabase));
            RegisterModule(new SpriteOutlineModule(this, m_EventSystem, m_UndoSystem, m_AssetDatabase, m_GUIUtility, new ShapeEditorFactory(), outlineTexture));
            RegisterModule(new SpritePhysicsShapeModule(this, m_EventSystem, m_UndoSystem, m_AssetDatabase, m_GUIUtility, new ShapeEditorFactory(), outlineTexture));
            RegisterCustomModules();
            UpdateAvailableModules();
        }
コード例 #25
0
ファイル: PlayerMap.cs プロジェクト: JakeJasko/Haven
    public void BuildTexture()
    {
        // Determine mesh texture resolution
        int texWidth = size_x * Tileset.tile_width; // + Tileset.tile_width / 2;
        int texHeight = size_y * Tileset.tile_height; // + Tileset.tile_height / 2;

        // Instantiate empty texture for mesh
        Texture2D texture = new Texture2D(texWidth, texHeight);

        // Initialize clear texture if unset previously
        if (clear_tex == null) {
            clear_tex = new Color[texWidth * texHeight];
            for (int i = 0; i < clear_tex.Length; i++)
                clear_tex[i] = Color.clear;
        }

        // Initialize texture to transparent
        texture.SetPixels (0, 0, texWidth, texHeight, clear_tex);

        // Handles map drawing logic
        DrawMap(texture);

        // Point filter does no pixel blending
        texture.filterMode = FilterMode.Point;
        texture.Apply();

        // Assigns generated texture to mesh object
        MeshRenderer mesh_renderer = GetComponent<MeshRenderer>();
        mesh_renderer.material.mainTexture = texture;
    }
コード例 #26
0
ファイル: ColorView.cs プロジェクト: keny91/KinectGame
	// Update is called once per frame
	void Update () {
        if (colorMyMang == null)
        {
            return;
        }

        if (Input.GetButtonDown("Fire1"))
        {
            Debug.Log(Input.mousePosition);

            _ColorManager = colorMyMang.GetComponent<colorMyMang>();
            if(_ColorManager == null)
            {
                return;
            }

            ttt = _ColorManager.GetColorTexture();
            Texture2D result = new Texture2D((int)1024, (int)1024);
            result.SetPixels(ttt.GetPixels(Mathf.FloorToInt(448),Mathf.FloorToInt(28),Mathf.FloorToInt(1024),Mathf.FloorToInt(1024)));
            //TextureScale.Bilinear(result, 32, 32);
            TextureScale.Bilinear(result, 32, 32);
            


            byte[] bytes = result.EncodeToPNG();
            File.WriteAllBytes("SavedScreen.png", bytes);
            cubeRR.GetComponent<Renderer>().material.mainTexture = ttt;

        }
	}
コード例 #27
0
 public static Texture2D Crop(this Sprite s)
 {
     var t = new Texture2D((int)s.rect.width, (int)s.rect.height,TextureFormat.ARGB32, false,true);
     t.SetPixels(s.texture.GetPixels((int)s.textureRect.x, (int)s.textureRect.y, (int)s.textureRect.width, (int)s.textureRect.height));
     t.Apply();
     return t;
 }
コード例 #28
0
    public override void DisplayMap(float[,] heightMap)
    {
        int width = heightMap.GetLength(0);
        int height = heightMap.GetLength(1);
        Mesh mesh = CreateMesh(heightMap, heightMap.GetLength(0), heightMap.GetLength(1));

        meshFilter.mesh = mesh;

        Texture2D texture = new Texture2D(width, height);

        Color[] colorMap = new Color[width * height];
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                colorMap[y * width + x] = GetColorForIntensity(heightMap[x, y]);
            }
        }

        texture.SetPixels(colorMap);
        texture.Apply();

        textureRenderer.sharedMaterial.mainTexture = texture;
        transform.localScale = Vector3.one;
    }
コード例 #29
0
ファイル: Helpers.cs プロジェクト: JamesPersaud/goffmogLD30
        public static Texture2D getPlanetTexture(Body body)
        {
            Texture2D tex = new Texture2D(NOISE_TEXTURE_SIZE, NOISE_TEXTURE_SIZE);
            Color[] cols = new Color[NOISE_TEXTURE_SIZE * NOISE_TEXTURE_SIZE];

            int x = 0;
            int y = 0;
            while (y < tex.height)
            {
                x = 0;
                while (x < tex.width)
                {
                    float xCoord = perlinX + (float)x / tex.width * 2f * body.BodyRadius;
                    float yCoord = perlinY + (float)y / tex.height * 2f * body.BodyRadius;
                    float sample = Mathf.PerlinNoise(xCoord, yCoord);
                    cols[y * tex.width + x] = Color.Lerp(body.SkyColor, body.CloudColor, sample);
                    x++;
                }
                y++;
            }

            perlinX = x;
            perlinY = y;

            tex.SetPixels(cols);
            tex.Apply();

            return tex;
        }
コード例 #30
0
ファイル: Part_Eye.cs プロジェクト: MrImitate/Procedural-Gen
	public override Texture2D CreateSprite (Texture2D texture)
	{
		Color[] pixels = texture.GetPixels ();
		Color[,] pixels2D = new Color[texture.width, texture.height];
		for (int i = 0; i < pixels.Length; i++) {
			
			int x = i % texture.width;
			int y = i / texture.height;

			pixels2D [x, y] = pixels [i];
		}

		int amountOfEyes = (int)(sightAngle / 45);
		for (int i = 0; i < amountOfEyes; i++) {
			
			int radius = (texture.width - eyeSize) / 2;
			float xPos = Mathf.Sin (Mathf.Deg2Rad * (i * 45));
			float yPos = Mathf.Cos (Mathf.Deg2Rad * (i * 45));
			Vector2 pos = new Vector2 (xPos, yPos) * radius + new Vector2 (texture.width - eyeSize, texture.height - eyeSize) / 2;

			ApplyKernel (ref pixels2D, texture.width, texture.height, pos);
		}

		for (int x = 0; x < pixels2D.GetLength (0); x++) {
			for (int y = 0; y < pixels2D.GetLength (1); y++) {
				
				pixels [x + y * texture.width] = pixels2D [x, y];
			}
		}

		texture.SetPixels (pixels);
		texture.Apply ();

		return texture;
	}
コード例 #31
0
ファイル: InputController.cs プロジェクト: Headsta/Boxworld
 private void CreateGrassTexture()
 {
     grassTexture = new Texture2D(2,2);
     grassTexture.SetPixels(new Color[]{Color.green,Color.green,Color.green,Color.green});
     grassTexture.filterMode = FilterMode.Point;
     grassTexture.Apply();
 }
コード例 #32
0
        public static bool LoadTexture2DLutFromImage( Texture2D texture, ToolSettings settings, out Texture2D lutTexture )
        {
            var width = settings.Resolution.TargetWidth;
            var height = settings.Resolution.TargetHeight;

            var size = settings.LUT.Size;
            var cols = settings.LUT.Columns;
            var rows = settings.LUT.Rows;

            var imageData = texture.GetPixels();

            var lutText = new Texture2D( size * size, size, TextureFormat.ARGB32, false );
            var lutData = new Color[ size * size * size ];

            for ( int h = 0, i = 0; h < size; h++ )
            {
                for ( int r = 0; r < rows; r++ )
                {
                    for ( int w = 0; w < size * cols; w++ )
                    {
                        var x = w;
                        var y = h + r * size;
                        y = height - 1 - y;
                        lutData[ i++ ] = imageData[ x + y * width ];
                    }
                }
            }

            lutText.SetPixels( lutData );
            lutText.Apply();
            lutTexture = lutText;

            return true;
        }
コード例 #33
0
    static int SetPixels(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Texture2D.Register");
#endif
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                UnityEngine.Texture2D obj  = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
                UnityEngine.Color[]   arg0 = ToLua.CheckStructArray <UnityEngine.Color>(L, 2);
                obj.SetPixels(arg0);
                return(0);
            }
            else if (count == 3)
            {
                UnityEngine.Texture2D obj  = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
                UnityEngine.Color[]   arg0 = ToLua.CheckStructArray <UnityEngine.Color>(L, 2);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                obj.SetPixels(arg0, arg1);
                return(0);
            }
            else if (count == 6)
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                int arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
                int arg3 = (int)LuaDLL.luaL_checknumber(L, 5);
                UnityEngine.Color[] arg4 = ToLua.CheckStructArray <UnityEngine.Color>(L, 6);
                obj.SetPixels(arg0, arg1, arg2, arg3, arg4);
                return(0);
            }
            else if (count == 7)
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                int arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
                int arg3 = (int)LuaDLL.luaL_checknumber(L, 5);
                UnityEngine.Color[] arg4 = ToLua.CheckStructArray <UnityEngine.Color>(L, 6);
                int arg5 = (int)LuaDLL.luaL_checknumber(L, 7);
                obj.SetPixels(arg0, arg1, arg2, arg3, arg4, arg5);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Texture2D.SetPixels"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #34
0
    static int SetPixels(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Texture2D), typeof(UnityEngine.Color[])))
            {
                UnityEngine.Texture2D obj  = (UnityEngine.Texture2D)ToLua.ToObject(L, 1);
                UnityEngine.Color[]   arg0 = ToLua.CheckObjectArray <UnityEngine.Color>(L, 2);
                obj.SetPixels(arg0);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Texture2D), typeof(UnityEngine.Color[]), typeof(int)))
            {
                UnityEngine.Texture2D obj  = (UnityEngine.Texture2D)ToLua.ToObject(L, 1);
                UnityEngine.Color[]   arg0 = ToLua.CheckObjectArray <UnityEngine.Color>(L, 2);
                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                obj.SetPixels(arg0, arg1);
                return(0);
            }
            else if (count == 6 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Texture2D), typeof(int), typeof(int), typeof(int), typeof(int), typeof(UnityEngine.Color[])))
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.ToObject(L, 1);
                int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                int arg3 = (int)LuaDLL.lua_tonumber(L, 5);
                UnityEngine.Color[] arg4 = ToLua.CheckObjectArray <UnityEngine.Color>(L, 6);
                obj.SetPixels(arg0, arg1, arg2, arg3, arg4);
                return(0);
            }
            else if (count == 7 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Texture2D), typeof(int), typeof(int), typeof(int), typeof(int), typeof(UnityEngine.Color[]), typeof(int)))
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.ToObject(L, 1);
                int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                int arg3 = (int)LuaDLL.lua_tonumber(L, 5);
                UnityEngine.Color[] arg4 = ToLua.CheckObjectArray <UnityEngine.Color>(L, 6);
                int arg5 = (int)LuaDLL.lua_tonumber(L, 7);
                obj.SetPixels(arg0, arg1, arg2, arg3, arg4, arg5);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Texture2D.SetPixels"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #35
0
    static int SetPixels(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                UnityEngine.Texture2D obj  = (UnityEngine.Texture2D)ToLua.CheckObject <UnityEngine.Texture2D>(L, 1);
                UnityEngine.Color[]   arg0 = ToLua.CheckStructArray <UnityEngine.Color>(L, 2);
                obj.SetPixels(arg0);
                return(0);
            }
            else if (count == 3)
            {
                UnityEngine.Texture2D obj  = (UnityEngine.Texture2D)ToLua.CheckObject <UnityEngine.Texture2D>(L, 1);
                UnityEngine.Color[]   arg0 = ToLua.CheckStructArray <UnityEngine.Color>(L, 2);
                int arg1 = (int)LuaDLL.luaL_checkinteger(L, 3);
                obj.SetPixels(arg0, arg1);
                return(0);
            }
            else if (count == 6)
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.CheckObject <UnityEngine.Texture2D>(L, 1);
                int arg0 = (int)LuaDLL.luaL_checkinteger(L, 2);
                int arg1 = (int)LuaDLL.luaL_checkinteger(L, 3);
                int arg2 = (int)LuaDLL.luaL_checkinteger(L, 4);
                int arg3 = (int)LuaDLL.luaL_checkinteger(L, 5);
                UnityEngine.Color[] arg4 = ToLua.CheckStructArray <UnityEngine.Color>(L, 6);
                obj.SetPixels(arg0, arg1, arg2, arg3, arg4);
                return(0);
            }
            else if (count == 7)
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.CheckObject <UnityEngine.Texture2D>(L, 1);
                int arg0 = (int)LuaDLL.luaL_checkinteger(L, 2);
                int arg1 = (int)LuaDLL.luaL_checkinteger(L, 3);
                int arg2 = (int)LuaDLL.luaL_checkinteger(L, 4);
                int arg3 = (int)LuaDLL.luaL_checkinteger(L, 5);
                UnityEngine.Color[] arg4 = ToLua.CheckStructArray <UnityEngine.Color>(L, 6);
                int arg5 = (int)LuaDLL.luaL_checkinteger(L, 7);
                obj.SetPixels(arg0, arg1, arg2, arg3, arg4, arg5);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Texture2D.SetPixels"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #36
0
 static int QPYX_SetPixels_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 2)
         {
             UnityEngine.Texture2D QPYX_obj_YXQP  = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Texture2D));
             UnityEngine.Color[]   QPYX_arg0_YXQP = ToLua.CheckStructArray <UnityEngine.Color>(L_YXQP, 2);
             QPYX_obj_YXQP.SetPixels(QPYX_arg0_YXQP);
             return(0);
         }
         else if (QPYX_count_YXQP == 3)
         {
             UnityEngine.Texture2D QPYX_obj_YXQP  = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Texture2D));
             UnityEngine.Color[]   QPYX_arg0_YXQP = ToLua.CheckStructArray <UnityEngine.Color>(L_YXQP, 2);
             int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3);
             QPYX_obj_YXQP.SetPixels(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
             return(0);
         }
         else if (QPYX_count_YXQP == 6)
         {
             UnityEngine.Texture2D QPYX_obj_YXQP = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Texture2D));
             int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
             int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3);
             int QPYX_arg2_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 4);
             int QPYX_arg3_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 5);
             UnityEngine.Color[] QPYX_arg4_YXQP = ToLua.CheckStructArray <UnityEngine.Color>(L_YXQP, 6);
             QPYX_obj_YXQP.SetPixels(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP, QPYX_arg4_YXQP);
             return(0);
         }
         else if (QPYX_count_YXQP == 7)
         {
             UnityEngine.Texture2D QPYX_obj_YXQP = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Texture2D));
             int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
             int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3);
             int QPYX_arg2_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 4);
             int QPYX_arg3_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 5);
             UnityEngine.Color[] QPYX_arg4_YXQP = ToLua.CheckStructArray <UnityEngine.Color>(L_YXQP, 6);
             int QPYX_arg5_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 7);
             QPYX_obj_YXQP.SetPixels(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP, QPYX_arg4_YXQP, QPYX_arg5_YXQP);
             return(0);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Texture2D.SetPixels"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
コード例 #37
0
    private UnityEngine.Texture2D MakeTexture(int width, int height, UnityEngine.Color col)
    {
        UnityEngine.Color[] pix = new UnityEngine.Color[width * height];

        for (int i = 0; i < pix.Length; i++)
        {
            pix[i] = col;
        }

        UnityEngine.Texture2D result = new UnityEngine.Texture2D(width, height);
        result.SetPixels(pix);
        result.Apply();

        return(result);
    }
コード例 #38
0
ファイル: DTexture.cs プロジェクト: Tiburrs/Project-Gravitum
 public UnityEngine.Texture2D CreateTexture2D()
 {
     UnityEngine.Texture2D tex = new UnityEngine.Texture2D(this.width, this.height);
     UnityEngine.Color[]   c   = new UnityEngine.Color[colors.Length];
     for (int i = 0; i < colors.Length; i++)
     {
         c[i].r = colors[i];
         c[i].g = colors[i];
         c[i].b = colors[i];
         c[i].a = 1;
     }
     tex.SetPixels(c);
     tex.Apply();
     return(tex);
 }
コード例 #39
0
 public static int SetPixels_wrap(long L)
 {
     try
     {
         long nThisPtr             = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.Texture2D obj = get_obj(nThisPtr);
         Color[] arg0 = null;
         arg0 = FCCustomParam.GetArray(ref arg0, L, 0);
         obj.SetPixels(arg0);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
コード例 #40
0
 public static int SetPixels2_wrap(long L)
 {
     try
     {
         long nThisPtr             = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.Texture2D obj = get_obj(nThisPtr);
         int     arg0 = FCLibHelper.fc_get_int(L, 0);
         int     arg1 = FCLibHelper.fc_get_int(L, 1);
         int     arg2 = FCLibHelper.fc_get_int(L, 2);
         int     arg3 = FCLibHelper.fc_get_int(L, 3);
         Color[] arg4 = null;
         arg4 = FCCustomParam.GetArray(ref arg4, L, 4);
         int arg5 = FCLibHelper.fc_get_int(L, 5);
         obj.SetPixels(arg0, arg1, arg2, arg3, arg4, arg5);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
コード例 #41
0
        public static void SetTextureData(UnityEngine.Texture2D texture, Alt.Sketch.Bitmap src, Alt.Sketch.RectI srcRect, bool flip)
        {
            if (texture == null ||
                src == null ||
                !src.IsValid)
            {
                return;
            }


            Alt.Sketch.BitmapData srcData = src.LockBits(Sketch.ImageLockMode.ReadOnly);
            if (srcData == null)
            {
                return;
            }


            int src_x = srcRect.X;
            int src_y = srcRect.Y;
            //int src_w, src_h;
            int src_width =             //src_w =
                            srcRect.Width;
            int src_height =            //src_h =
                             srcRect.Height;

            int dest_x = 0;
            int dest_y = 0;

            int dest_w = texture.width;
            int dest_h = texture.height;

            if (dest_x > (dest_w - 1) ||
                dest_y > (dest_h - 1))
            {
                src.UnlockBits(srcData);

                return;
            }

            if ((dest_x + src_width) > dest_w)
            {
                src_width = dest_w - dest_x;
            }

            if ((dest_y + src_height) > dest_h)
            {
                src_height = dest_h - dest_y;
            }


            byte[] src_Buffer    = srcData.Scan0;
            int    src_stride    = srcData.Stride;
            int    src_ByteDepth = srcData.ByteDepth;


            try
            {
                bool fProcessed = false;

                switch (srcData.PixelFormat)
                {
                case Sketch.PixelFormat.Format24bppRgb:
                {
                    switch (texture.format)
                    {
                    case TextureFormat.RGB24:
                    {
                        if (src_width == dest_w &&
                            src_height == dest_h)
                        {
                            //texture.LoadRawTextureData(src_Buffer);

                            byte[] colors = src.TextureTempBuffer;
                            if (colors == null)
                            {
                                colors = new byte[src_height * src_width * 3];
                            }
                            int colors_index = 0;

                            if (flip)
                            {
                                for (int y = src_height - 1; y >= 0; y--)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = src_Buffer[src_Index + 2];
                                        colors[colors_index++] = src_Buffer[src_Index + 1];
                                        colors[colors_index++] = src_Buffer[src_Index];
                                        src_Index += 3;
                                    }
                                }
                            }
                            else
                            {
                                for (int y = 0; y < src_height; y++)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = src_Buffer[src_Index + 2];
                                        colors[colors_index++] = src_Buffer[src_Index + 1];
                                        colors[colors_index++] = src_Buffer[src_Index];
                                        src_Index += 3;
                                    }
                                }
                            }

                            texture.LoadRawTextureData(colors);
                        }
                        else
                        {
                            UnityEngine.Color[] colors = new UnityEngine.Color[src_height * src_width];
                            int colors_index           = 0;

                            if (flip)
                            {
                                for (int y = src_height - 1; y >= 0; y--)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = new Color32(
                                            src_Buffer[src_Index + 2],
                                            src_Buffer[src_Index + 1],
                                            src_Buffer[src_Index],
                                            255);
                                        src_Index += 3;
                                    }
                                }
                            }
                            else
                            {
                                for (int y = 0; y < src_height; y++)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = new Color32(
                                            src_Buffer[src_Index + 2],
                                            src_Buffer[src_Index + 1],
                                            src_Buffer[src_Index],
                                            255);
                                        src_Index += 3;
                                    }
                                }
                            }

                            texture.SetPixels(src_x, src_y, src_width, src_height, colors);
                        }

                        fProcessed = true;

                        break;
                    }

                    case TextureFormat.RGBA32:
                    {
                        if (src_width == dest_w &&
                            src_height == dest_h)
                        {
                            byte[] colors       = new byte[src_height * src_width * 4];
                            int    colors_index = 0;

                            if (flip)
                            {
                                for (int y = src_height - 1; y >= 0; y--)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = src_Buffer[src_Index + 2];
                                        colors[colors_index++] = src_Buffer[src_Index + 1];
                                        colors[colors_index++] = src_Buffer[src_Index];
                                        colors[colors_index++] = 255;
                                        src_Index += 3;
                                    }
                                }
                            }
                            else
                            {
                                for (int y = 0; y < src_height; y++)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = src_Buffer[src_Index + 2];
                                        colors[colors_index++] = src_Buffer[src_Index + 1];
                                        colors[colors_index++] = src_Buffer[src_Index];
                                        colors[colors_index++] = 255;
                                        src_Index += 3;
                                    }
                                }
                            }

                            texture.LoadRawTextureData(colors);
                        }
                        else
                        {
                            UnityEngine.Color[] colors = new UnityEngine.Color[src_height * src_width];
                            int colors_index           = 0;

                            if (flip)
                            {
                                for (int y = src_height - 1; y >= 0; y--)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = new Color32(
                                            src_Buffer[src_Index + 2],
                                            src_Buffer[src_Index + 1],
                                            src_Buffer[src_Index],
                                            255);
                                        src_Index += 3;
                                    }
                                }
                            }
                            else
                            {
                                for (int y = 0; y < src_height; y++)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = new Color32(
                                            src_Buffer[src_Index + 2],
                                            src_Buffer[src_Index + 1],
                                            src_Buffer[src_Index],
                                            255);
                                        src_Index += 3;
                                    }
                                }
                            }

                            texture.SetPixels(src_x, src_y, src_width, src_height, colors);
                        }

                        fProcessed = true;

                        break;
                    }
                    }

                    break;
                }

                case Sketch.PixelFormat.Format32bppArgb:
                {
                    switch (texture.format)
                    {
                    case TextureFormat.RGB24:
                    {
                        //  We can't be here

                        //int dest_ByteDepth = 3;

                        break;
                    }

                    case TextureFormat.RGBA32:
                    {
                        if (src_width == dest_w &&
                            src_height == dest_h)
                        {
                            //texture.LoadRawTextureData(src_Buffer);

                            byte[] colors = src.TextureTempBuffer;
                            if (colors == null)
                            {
                                colors = new byte[src_height * src_width * 4];
                            }
                            int colors_index = 0;

                            if (flip)
                            {
                                for (int y = src_height - 1; y >= 0; y--)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = src_Buffer[src_Index + 2];
                                        colors[colors_index++] = src_Buffer[src_Index + 1];
                                        colors[colors_index++] = src_Buffer[src_Index];
                                        colors[colors_index++] = src_Buffer[src_Index + 3];
                                        src_Index += 4;
                                    }
                                }
                            }
                            else
                            {
                                for (int y = 0; y < src_height; y++)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = src_Buffer[src_Index + 2];
                                        colors[colors_index++] = src_Buffer[src_Index + 1];
                                        colors[colors_index++] = src_Buffer[src_Index];
                                        colors[colors_index++] = src_Buffer[src_Index + 3];
                                        src_Index += 4;
                                    }
                                }
                            }

                            texture.LoadRawTextureData(colors);
                        }
                        else
                        {
                            UnityEngine.Color[] colors = new UnityEngine.Color[src_height * src_width];
                            int colors_index           = 0;

                            if (flip)
                            {
                                for (int y = src_height - 1; y >= 0; y--)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = new Color32(
                                            src_Buffer[src_Index + 2],
                                            src_Buffer[src_Index + 1],
                                            src_Buffer[src_Index],
                                            src_Buffer[src_Index + 3]);
                                        src_Index += 4;
                                    }
                                }
                            }
                            else
                            {
                                for (int y = 0; y < src_height; y++)
                                {
                                    int src_Index = src_x * src_ByteDepth + (src_y + y) * src_stride;

                                    for (int x = 0; x < src_width; x++)
                                    {
                                        colors[colors_index++] = new Color32(
                                            src_Buffer[src_Index + 2],
                                            src_Buffer[src_Index + 1],
                                            src_Buffer[src_Index],
                                            src_Buffer[src_Index + 3]);
                                        src_Index += 4;
                                    }
                                }
                            }

                            texture.SetPixels(src_x, src_y, src_width, src_height, colors);
                        }

                        fProcessed = true;

                        break;
                    }
                    }

                    break;
                }

                case Sketch.PixelFormat.Format8bppAlpha:
                {
                    //  not used yet

                    break;
                }
                }


                //  universal method
                if (!fProcessed)
                {
                    UnityEngine.Color[] colors = new UnityEngine.Color[src_height * src_width];
                    int colors_index           = 0;

                    for (int y = 0; y < src_height; y++)
                    {
                        for (int x = 0; x < src_width; x++)
                        {
                            Alt.Sketch.Color color = src.GetPixel(x, y);

                            colors[colors_index++] = new Color32(
                                color.R,
                                color.G,
                                color.B,
                                color.A);
                        }
                    }

                    texture.SetPixels(src_x, src_y, src_width, src_height, colors);

                    fProcessed = true;
                }

                if (fProcessed)
                {
                    texture.Apply(false);
                }
            }
            catch             //(System.Exception ex)
            {
                //Console.WriteLine(ex.ToString());
            }
            finally
            {
                src.UnlockBits(srcData);
            }
        }
コード例 #42
0
 static public int SetPixels(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
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             UnityEngine.Color[]   a1;
             checkArray(l, 2, out a1);
             self.SetPixels(a1);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             UnityEngine.Color[]   a1;
             checkArray(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             self.SetPixels(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 6)
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             System.Int32          a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Int32 a4;
             checkType(l, 5, out a4);
             UnityEngine.Color[] a5;
             checkArray(l, 6, out a5);
             self.SetPixels(a1, a2, a3, a4, a5);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 7)
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             System.Int32          a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Int32 a4;
             checkType(l, 5, out a4);
             UnityEngine.Color[] a5;
             checkArray(l, 6, out a5);
             System.Int32 a6;
             checkType(l, 7, out a6);
             self.SetPixels(a1, a2, a3, a4, a5, a6);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function SetPixels to call");
         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
 }
コード例 #43
0
 public override void SetPixels(Color[] c)
 {
     m_Texture.SetPixels(c);
 }
コード例 #44
0
        internal static UnityEngine.Texture2D BlitTexture(UnityEngine.Texture2D texture, UnityEngine.TextureFormat format, bool alphaOnly = false)
        {
            var texPath = AssetDatabase.GetAssetPath(texture);
            var asset   = AssetDatabase.LoadMainAssetAtPath(texPath);
            RenderTextureReadWrite rtReadWrite = UnityEngine.RenderTextureReadWrite.sRGB;

            if (asset is Texture2D)
            {
                var importer = (TextureImporter)AssetImporter.GetAtPath(texPath);
                if (importer != null)
                {
                    rtReadWrite = importer.sRGBTexture ? UnityEngine.RenderTextureReadWrite.sRGB : UnityEngine.RenderTextureReadWrite.Linear;
                }
            }

            // hack to support text mesh pro
            var fontAssetType = Type.GetType("TMPro.TMP_FontAsset, Unity.TextMeshPro, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");

            if (fontAssetType != null && fontAssetType.IsInstanceOfType(asset))
            {
                // TMPro texture atlases are always Linear space
                rtReadWrite = UnityEngine.RenderTextureReadWrite.Linear;
            }

            // Create a temporary RenderTexture of the same size as the texture
            var tmp = UnityEngine.RenderTexture.GetTemporary(
                texture.width,
                texture.height,
                0,
                UnityEngine.RenderTextureFormat.Default,
                rtReadWrite);

            // Blit the pixels on texture to the RenderTexture
            UnityEngine.Graphics.Blit(texture, tmp);

            // Backup the currently set RenderTexture
            var previous = UnityEngine.RenderTexture.active;

            // Set the current RenderTexture to the temporary one we created
            UnityEngine.RenderTexture.active = tmp;

            // Create a new readable Texture2D to copy the pixels to it
            var result = new UnityEngine.Texture2D(texture.width, texture.height, format, false);

            // Copy the pixels from the RenderTexture to the new Texture
            result.ReadPixels(new UnityEngine.Rect(0, 0, tmp.width, tmp.height), 0, 0);
            result.Apply();

            // Broadcast alpha to color
            if (alphaOnly || !HasColor(texture))
            {
                var pixels = result.GetPixels();
                for (var i = 0; i < pixels.Length; i++)
                {
                    pixels[i].r = pixels[i].a;
                    pixels[i].g = pixels[i].a;
                    pixels[i].b = pixels[i].a;
                }

                result.SetPixels(pixels);
                result.Apply();
            }

            // Reset the active RenderTexture
            UnityEngine.RenderTexture.active = previous;

            // Release the temporary RenderTexture
            UnityEngine.RenderTexture.ReleaseTemporary(tmp);
            return(result);
        }
コード例 #45
0
 static public int SetPixels(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 7)
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             System.Int32          a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Int32 a4;
             checkType(l, 5, out a4);
             UnityEngine.Color[] a5;
             checkArray(l, 6, out a5);
             System.Int32 a6;
             checkType(l, 7, out a6);
             self.SetPixels(a1, a2, a3, a4, a5, a6);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 6)
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             System.Int32          a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Int32 a4;
             checkType(l, 5, out a4);
             UnityEngine.Color[] a5;
             checkArray(l, 6, out a5);
             self.SetPixels(a1, a2, a3, a4, a5);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             UnityEngine.Color[]   a1;
             checkArray(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             self.SetPixels(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 2)
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             UnityEngine.Color[]   a1;
             checkArray(l, 2, out a1);
             self.SetPixels(a1);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #46
0
    // Update is called once per frame
    void Update()
    {
        //Added by Yuqi Ding
        MetaCoreInterop.meta_get_point_cloud(ref _metaPointCloud, _translation, _rotation);

        // obtain the rgb data
        MetaCoreInterop.meta_get_rgb_frame(RawPixelBuffer, _translation_rgb, _new_rotation_rgb);  // The buffer is pre-allocated by constructor.

        // obtain the rgb data parameter
        MetaCoreInterop.meta_get_rgb_intrinsics(ref _camera_params);

        // Check for a difference
        bool isEqual = true;

        // Check for a difference in pose (should change with each new RGB frame).
        for (int i = 0; i < _new_rotation_rgb.Length; ++i)
        {
            isEqual = _rotation_rgb[i] == _new_rotation_rgb[i];

            if (!isEqual)
            {
                break;
            }
        }

        // If the two rotations are not equal, we have a new rgb frame.
        if (!isEqual)
        {
            // Copy new rotation if it's different.
            for (int i = 0; i < _new_rotation_rgb.Length; ++i)
            {
                _rotation_rgb[i] = _new_rotation_rgb[i];
            }

            _rgbTexture.LoadRawTextureData(RawPixelBuffer, _totalBufferSize);
            _rgbTexture.Apply();
        }

        SetDepthToWorldTransform();

        if (SavePointCloud && (Time.frameCount % 48 == 0))
        {
            MarshalMetaPointCloud();

            int num = _metaPointCloud.num_points;
            if (num != 0)
            {
                //save the point cloud
                string PointCloudName = string.Format("{0}/{1:D04} shot.ply", folder, Time.frameCount);
                SavePointCloudToPly(PointCloudName, _pointCloud);
                string PointCloudIntrName = string.Format("{0}/{1:D04} pointcloud_Intr.txt", folder, Time.frameCount);
                SavePointCloudPara(PointCloudIntrName, _translation, _rotation);

                //save the rgb frame
                Color[] color2dtemp = _rgbTexture.GetPixels();
                for (int i = 0; i < color2dtemp.Length; i++)
                {
                    float temp = 0.0f;
                    temp             = color2dtemp[i].r;
                    color2dtemp[i].r = color2dtemp[i].b;
                    color2dtemp[i].b = temp;
                }
                _rgbTexture.SetPixels(color2dtemp);
                //Debug.Log("Swap r and b");

                byte[] bytes   = _rgbTexture.EncodeToJPG();
                string rgbName = string.Format("{0}/{1:D04} shot.jpg", folder, Time.frameCount);
                File.WriteAllBytes(rgbName, bytes);
                string rgbIntrName = string.Format("{0}/{1:D04} shot_Intr.txt", folder, Time.frameCount);
                SaveRGBIntrinsics(rgbIntrName, _camera_params);
                string rgbParaName = string.Format("{0}/{1:D04} shot_Para.txt", folder, Time.frameCount);
                SaveRGBPara(rgbParaName, _translation_rgb, _rotation_rgb);
            }
            // Added end
        }
    }
コード例 #47
0
 static public int SetPixels(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(UnityEngine.Color[])))
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             UnityEngine.Color[]   a1;
             checkType(l, 2, out a1);
             self.SetPixels(a1);
             return(0);
         }
         else if (matchType(l, 2, typeof(UnityEngine.Color[]), typeof(int)))
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             UnityEngine.Color[]   a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             self.SetPixels(a1, a2);
             return(0);
         }
         else if (matchType(l, 2, typeof(int), typeof(int), typeof(int), typeof(int), typeof(UnityEngine.Color[]), typeof(int)))
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             System.Int32          a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Int32 a4;
             checkType(l, 5, out a4);
             UnityEngine.Color[] a5;
             checkType(l, 6, out a5);
             System.Int32 a6;
             checkType(l, 7, out a6);
             self.SetPixels(a1, a2, a3, a4, a5, a6);
             return(0);
         }
         else if (matchType(l, 2, typeof(int), typeof(int), typeof(int), typeof(int), typeof(UnityEngine.Color[])))
         {
             UnityEngine.Texture2D self = (UnityEngine.Texture2D)checkSelf(l);
             System.Int32          a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Int32 a4;
             checkType(l, 5, out a4);
             UnityEngine.Color[] a5;
             checkType(l, 6, out a5);
             self.SetPixels(a1, a2, a3, a4, a5);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }