当前位置: 首页>>代码示例>>C#>>正文


C# Texture2D.GetPixels方法代码示例

本文整理汇总了C#中UnityEngine.Texture2D.GetPixels方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.GetPixels方法的具体用法?C# Texture2D.GetPixels怎么用?C# Texture2D.GetPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Texture2D的用法示例。


在下文中一共展示了Texture2D.GetPixels方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    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
    }
开发者ID:AVUIs,项目名称:un1c0rn3r,代码行数:34,代码来源:MuhShader.cs

示例2: getPlayerSprites

	public static GUIStyle[] getPlayerSprites(Texture2D playersTexture)
	{
		GUIStyle[] styles = new GUIStyle[4];		

		styles[0] = new GUIStyle ();
		Color[] button1Colors = playersTexture.GetPixels (0, 0, IMAGE_HEIGHT, IMAGE_HEIGHT);
		Texture2D button1Texture = new Texture2D(IMAGE_HEIGHT, IMAGE_HEIGHT);
		button1Texture.SetPixels(button1Colors);
		button1Texture.Apply ();
		styles[0].normal.background = button1Texture;

		styles[1] = new GUIStyle ();
		Color[] button2Colors = playersTexture.GetPixels (320, 0, IMAGE_HEIGHT, IMAGE_HEIGHT);
		Texture2D button2Texture = new Texture2D(IMAGE_HEIGHT, IMAGE_HEIGHT);
		button2Texture.SetPixels(button2Colors);
		button2Texture.Apply ();
		styles[1].normal.background = button2Texture;

		styles[2] = new GUIStyle ();
		Color[] button3Colors = playersTexture.GetPixels (640, 0, IMAGE_HEIGHT, IMAGE_HEIGHT);
		Texture2D button3Texture = new Texture2D(IMAGE_HEIGHT, IMAGE_HEIGHT);
		button3Texture.SetPixels(button3Colors);
		button3Texture.Apply ();
		styles[2].normal.background = button3Texture;

		styles[3] = new GUIStyle ();
		Color[] button4Colors = playersTexture.GetPixels (960, 0, IMAGE_HEIGHT, IMAGE_HEIGHT);
		Texture2D button4Texture = new Texture2D(IMAGE_HEIGHT, IMAGE_HEIGHT);
		button4Texture.SetPixels(button4Colors);
		button4Texture.Apply ();
		styles[3].normal.background = button4Texture;

		return styles;
	}
开发者ID:HoneyTribe,项目名称:Labirynth,代码行数:34,代码来源:SpritesLoader.cs

示例3: FlattenSSBump

    public static void FlattenSSBump(Texture2D Normal, bool flipXZ)
    {
        if (!flipXZ)
        {
            Texture2D SSBumpTex = new Texture2D(Normal.width, Normal.height, TextureFormat.RGB24, true);
            Color[] SSBumpColor;
            Color[] NormalColor;

            Vector4[] Basis = new Vector4[3];
            Basis[0] = new Vector4(0.816496580927726f, 0.0f, 0.5773502691896258f, 0.0f);
            Basis[1] = new Vector4(-0.408248290463863f, 0.7071067811865475f, 0.5773502691896258f, 0.0f);
            Basis[2] = new Vector4(-0.408248290463863f, -0.7071067811865475f, 0.5773502691896258f, 0.0f);

            //Make our Normal Texture readible temporarily
            TextureImporter tempRNMImport = TextureImporter.GetAtPath(AssetDatabase.GetAssetPath(Normal.GetInstanceID())) as TextureImporter;
            tempRNMImport.textureType = TextureImporterType.Image;
            tempRNMImport.isReadable = true;
            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(Normal.GetInstanceID()), ImportAssetOptions.ForceUpdate);

            SSBumpColor = Normal.GetPixels();
            NormalColor = Normal.GetPixels();

            for (int i = 0; i < SSBumpColor.Length; i++)
            {
                SSBumpColor[i].r = (DotBasis(UnpackNormal(NormalColor[i]), Basis[0]) + 1) / 2;
                SSBumpColor[i].g = (DotBasis(UnpackNormal(NormalColor[i]), Basis[1]) + 1) / 2;
                SSBumpColor[i].b = (DotBasis(UnpackNormal(NormalColor[i]), Basis[2]) + 1) / 2;
            }

            SSBumpTex.SetPixels(SSBumpColor);
            GzCRNMMergeUtil.TextureImportHelper(SSBumpTex, AssetDatabase.GetAssetPath(Normal.GetInstanceID()) + "_SSBump.png");

            tempRNMImport.textureType = TextureImporterType.Bump;
            tempRNMImport.isReadable = false;
            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(Normal.GetInstanceID()), ImportAssetOptions.ForceUpdate);
        }
        else
        {
            Color[] SSBumpColor;

            TextureImporter tempRNMImport = TextureImporter.GetAtPath(AssetDatabase.GetAssetPath(Normal.GetInstanceID())) as TextureImporter;
            tempRNMImport.isReadable = true;
            tempRNMImport.textureFormat = TextureImporterFormat.ARGB32;
            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(Normal.GetInstanceID()), ImportAssetOptions.ForceUpdate);
            SSBumpColor = Normal.GetPixels();
            for (int i = 0; i < SSBumpColor.Length; i++)
            {
                SSBumpColor[i].a = SSBumpColor[i].b;
                SSBumpColor[i].b = SSBumpColor[i].g;
                SSBumpColor[i].g = SSBumpColor[i].a;
                SSBumpColor[i].a = 0.0f;
            }

            Normal.SetPixels(SSBumpColor);
            GzCRNMMergeUtil.TextureImportHelper(Normal, AssetDatabase.GetAssetPath(Normal.GetInstanceID()) + "_ConvertedSSBump.png");
            tempRNMImport.isReadable = false;
            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(Normal.GetInstanceID()), ImportAssetOptions.ForceUpdate);
        }
    }
开发者ID:Avatarchik,项目名称:GzRNM,代码行数:59,代码来源:GzSSBumpConverterUtil.cs

示例4: DrawLine

    public static Texture2D DrawLine(Vector2 _from,Vector2 to, float w, Color col, Texture2D tex, bool stroke, Color strokeCol, float strokeWidth)
    {
        w = Mathf.Round (w);//It is important to round the numbers otherwise it will mess up with the texture width
        strokeWidth = Mathf.Round (strokeWidth);

        float extent = w + strokeWidth;

        float stY = Mathf.Clamp (Mathf.Min (_from.y,to.y)-extent,0,tex.height);//This is the topmost Y value
        float stX = Mathf.Clamp ((int)Mathf.Min (_from.x,to.x)-extent,0,(int)tex.width);
        float endY = Mathf.Clamp ((int)Mathf.Max (_from.y,to.y)+extent,0,(int)tex.height);
        float endX = Mathf.Clamp ((int)Mathf.Max (_from.x,to.x)+extent,0,(int)tex.width);//This is the rightmost Y value

        strokeWidth = strokeWidth/2;
        float strokeInner = (w-strokeWidth)*(w-strokeWidth);
        float strokeOuter = (w+strokeWidth)*(w+strokeWidth);
        float strokeOuter2 = (w+strokeWidth+1)*(w+strokeWidth+1);
        float sqrW = w*w;//It is much faster to calculate with squared values

        float lengthX = Mathf.Floor( endX-stX);
        float lengthY = Mathf.Floor( endY-stY);
        Vector2 start = new Vector2 (stX,stY);
        Color[] pixels = tex.GetPixels ((int)stX,(int)stY,(int)lengthX,(int)lengthY,0);//Get all pixels

        for (float y=0;y<lengthY;y++) {
            for (float x=0;x<lengthX;x++) {//Loop through the pixels
                Vector2 p = new Vector2 (x,y) + start;
                Vector2 center = p + new Vector2(0.5f,0.5f);
                float dist = (center-NearestPointStrict(_from,to,center)).sqrMagnitude;//The squared distance from the center of the pixels to the nearest point on the line
                if (dist<=strokeOuter2) {
                    Vector2 [] samples = Sample (p);
                    Color c = Color.clear;
                    Color pc = pixels[(int)(y*lengthX+x)];

                    for (int i=0;i<samples.Length;i++) {//Loop through the samples
                        dist = (samples[i]-NearestPointStrict(_from,to,samples[i])).sqrMagnitude;//The squared distance from the sample to the line
                        if (stroke) {
                            if (dist<=strokeOuter && dist >= strokeInner) {
                                c+=strokeCol;
                            } else if (dist<sqrW) {
                                c+=col;
                            } else {
                                c+=pc;
                            }
                        } else {
                            if (dist<sqrW) {//Is the distance smaller than the width of the line
                                c+=col;
                            } else {
                                c+=pc;//No it wasn't, set it to be the original colour
                            }
                        }
                    }
                    c /= samples.Length;//Get the avarage colour
                    pixels[(int)(y*lengthX+x)]=c;
                }
            }
        }
        tex.SetPixels ((int)stX,(int)stY,(int)lengthX,(int)lengthY,pixels,0);
        tex.Apply ();
        return tex;
    }
开发者ID:rahmanazhar,项目名称:UnityWorkspace,代码行数:60,代码来源:Drawing.cs

示例5: MakeBasis

    public static void MakeBasis(string name, Vector4 basisx, Vector4 basisy, Vector4 basisz)
    {
        Color[] cBasisx;
        Color[] cBasisy;
        Color[] cBasisz;
        Texture2D texBasisx = new Texture2D(16, 16);
        Texture2D texBasisy = new Texture2D(16, 16);
        Texture2D texBasisz = new Texture2D(16, 16);

        cBasisx = texBasisx.GetPixels();
        cBasisy = texBasisy.GetPixels();
        cBasisz = texBasisz.GetPixels();

        for (int i = 0; i < cBasisx.Length; i++)
        {
            cBasisx[i] = CompressedBasis(basisx);
            cBasisy[i] = CompressedBasis(basisy);
            cBasisz[i] = CompressedBasis(basisz);
        }

        texBasisx.SetPixels(cBasisx);
        texBasisy.SetPixels(cBasisy);
        texBasisz.SetPixels(cBasisz);
        if (!System.IO.Directory.Exists("Assets/GzRNM/BasisMaps"))
            System.IO.Directory.CreateDirectory("Assets/GzRNM/BasisMaps");
        GzCRNMMergeUtil.TextureImportHelper(texBasisx, "Assets/GzRNM/BasisMaps/Basis X.png");
        GzCRNMMergeUtil.TextureImportHelper(texBasisy, "Assets/GzRNM/BasisMaps/Basis Y.png");
        GzCRNMMergeUtil.TextureImportHelper(texBasisz, "Assets/GzRNM/BasisMaps/Basis Z.png");
    }
开发者ID:Avatarchik,项目名称:GzRNM,代码行数:29,代码来源:gzbasismakerutil.cs

示例6: ConvertTangentBasis

    /// <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;
    }
开发者ID:Geenz,项目名称:Gz-Unity-Tools,代码行数:35,代码来源:TexturesSpaceConverter.cs

示例7: Decode

	public static string Decode (Texture2D image){
		
		//Get the pixels for the image...
		Color[] imagePixels = image.GetPixels();
		
		//Go Through the First 32 Pixels and create a 4 byte array. 
		//This array should give us the message's length.	
		BitArray newBits = new BitArray(32);
		for (int i=0;i<32;i++){
			if(imagePixels[i].a == 1){
				newBits[i] = true;
			}
			else {
				newBits[i] = false;
			}
		}
		
		int total = System.BitConverter.ToInt32(ToByteArray(newBits), 0);
		BitArray messageBits = new BitArray(total);
		for (int j=32;j<total + 32;j++){
				if(imagePixels[j].a == 1){
					messageBits[j-32] = true;
				}
				else {
					messageBits[j-32] = false;
				}
		}
		
		return System.Text.Encoding.ASCII.GetString(ToByteArray(messageBits));
		
	}
开发者ID:rishabhjoshi,项目名称:Steganography-1,代码行数:31,代码来源:Steganography.cs

示例8: BuildTextureAtlas

    /// <summary>
    /// Builds the texture atlas.
    /// </summary>
    public static void BuildTextureAtlas()
    {
        // Build texture array
        Texture2D[] atlasTextures = new Texture2D[textures.Count];
        foreach (KeyValuePair<int, Texture2D> texture in textures)
        {
            atlasTextures[texture.Key] = texture.Value;
        }

        // Build atlas
        Texture2D _textureAtlas = new Texture2D (4096, 4096, TextureFormat.RGBA32, false);
        Rect[] uvRects = _textureAtlas.PackTextures (atlasTextures, 0);

        textureAtlas = new Texture2D(_textureAtlas.width, _textureAtlas.height, TextureFormat.RGBA32, false);
        textureAtlas.SetPixels (0,0,_textureAtlas.width, _textureAtlas.height, _textureAtlas.GetPixels (0,0,_textureAtlas.width, _textureAtlas.height));

        // Set texture atlas properties
        textureAtlas.anisoLevel = 9;
        textureAtlas.filterMode = FilterMode.Point;
        textureAtlas.Apply ();

        // Save uvs
        textureCoordinates = new Dictionary<int, Vector2[]> ();
        foreach (KeyValuePair<int, Texture2D> texture in textures)
        {
            textureCoordinates.Add (texture.Key,new Vector2[]
            {
                new Vector2(uvRects[texture.Key].x, uvRects[texture.Key].y),
                new Vector2(uvRects[texture.Key].x+uvRects[texture.Key].width, uvRects[texture.Key].y),
                new Vector2(uvRects[texture.Key].x+uvRects[texture.Key].width, uvRects[texture.Key].y+uvRects[texture.Key].height),
                new Vector2(uvRects[texture.Key].x, uvRects[texture.Key].y+uvRects[texture.Key].height)
            });
        }
    }
开发者ID:kennux,项目名称:cubicworld,代码行数:37,代码来源:Blocks.cs

示例9: Update

	// 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;

        }
	}
开发者ID:keny91,项目名称:KinectGame,代码行数:31,代码来源:ColorView.cs

示例10: OnPostprocessTexture

    void OnPostprocessTexture(Texture2D texture)
    {
        if (!assetPath.EndsWith (suffix)) {
            return;
        }

        // Make a mask texture temporary in true color.
        var mask = new Texture2D (texture.width, texture.height, TextureFormat.RGB24, false);
        mask.wrapMode = TextureWrapMode.Clamp;

        // Convert the source image into a mask.
        var pixels = texture.GetPixels ();
        for (int i = 0; i < pixels.Length; i++) {
            var a = pixels [i].a;
            pixels [i] = new Color (a, a, a);
        }
        mask.SetPixels (pixels);

        // Compress the mask in the proper compression format.
        EditorUtility.CompressTexture (mask, CompressionFormat, TextureCompressionQuality.Best);

        // Replace the asset which already exists, or create a new asset.
        var maskPath = assetPath.Replace (suffix, "mask.asset");
        var maskAsset = AssetDatabase.LoadAssetAtPath (maskPath, typeof(Texture2D)) as Texture2D;
        if (maskAsset == null) {
            AssetDatabase.CreateAsset (mask, maskPath);
        } else {
            EditorUtility.CopySerialized (mask, maskAsset);
        }

        // Compress the source texture.
        EditorUtility.CompressTexture (texture, CompressionFormat, TextureCompressionQuality.Best);
    }
开发者ID:proree88,项目名称:unity-alphamask,代码行数:33,代码来源:TextureModifier.cs

示例11: Porta

    public Porta(string nome,int offset, TipoDePorta tipo, WNode nodoPai)
    {

        Nome = nome;
        yOffset = offset;
        tipoDaPorta = tipo;
        nodoDono = nodoPai;
        cor = Color.white;
        switch(offset)
        {
            case 0: cor = Color.green; break;
            case 1: cor = Color.blue; break;
            case 2: cor = Color.red; break;
            case 3: cor = Color.yellow; break;
            case 4: cor = Color.black; break;
            case 5: cor = Color.cyan; break;
            default:
                
                Debug.LogError("erro cor da porta não suportada");
                break;
        }
        //guiskin = Resources.Load<GUISkin>("GUISkinNode");
        //   textura = Resources.Load<Texture2D>("CirculoBranco");
        textura = (Texture2D)Object.Instantiate(Resources.Load<Texture2D>("CirculoBranco"));
        Color[] colors = textura.GetPixels();
        for (int i = 0; i < colors.Length; i++)
        {
            if (colors[i].a != 0)
                colors[i] = cor;
        }
        textura.SetPixels(colors);
        textura.Apply();

    }
开发者ID:wenderRondonia,项目名称:Node-Editor-Unity,代码行数:34,代码来源:WLinks.cs

示例12: BlendMono

    public static Texture2D BlendMono(Texture2D a, Texture2D b, int mode)
    {
        IntPairClass resA = new IntPairClass(a);
        IntPairClass resB = new IntPairClass(b);
        IntPairClass res = new IntPairClass();
        res.SetFromMinimum(resA, resB);

        Color[] originalColorsA = a.GetPixels(0, 0, res.value01, res.value02);
        Color[] originalColorsB = b.GetPixels(0, 0, res.value01, res.value02);
        Color[] resultColors = new Color[originalColorsA.Length];

        for (int i = 0; i < resultColors.Length; i++)
        {
            float aValue = originalColorsA[i].a;
            float bValue = originalColorsB[i].a;
            Color r = new Color();
            if (mode == 0 || mode == 1)
            {
                r = new Color(1f, 1f, 1f, aValue);
            }
            else if(mode == 2)
            {
                r = new Color(1f, 1f, 1f, aValue * bValue);
            }
            resultColors[i] = r;
        }

        Texture2D toReturn = new Texture2D(a.width, a.height, TextureFormat.Alpha8, true);
        toReturn.SetPixels(0, 0, a.width, a.height, resultColors);
        toReturn.Apply(true);
        return toReturn;
    }
开发者ID:Angel07,项目名称:Node_Editor,代码行数:32,代码来源:ImageProcessorTypes.cs

示例13: CreatePreviewTexture

 private static Texture2D CreatePreviewTexture(Texture2D page)
 {
     if (page != null)
     {
         Texture2D preview = new Texture2D(page.width, page.height, TextureFormat.ARGB32, true);
         preview.filterMode = FilterMode.Bilinear;
         Color[] contents = page.GetPixels();
         var magenta = Color.magenta;
         var s = contents.Length;
         for (var i = 0; i < s; ++i)
         {
             var newCol = contents[i];
             var sa = newCol.a;
             var da = 1 - sa;
             contents[i].r = newCol.r * sa + magenta.r * da;
             contents[i].g = newCol.g * sa + magenta.g * da;
             contents[i].b = newCol.b * sa + magenta.b * da;
             contents[i].a = 1;
         }
         preview.SetPixels(contents);
         preview.Apply(true, true);
         return preview;
     }
     else
     {
         return null;
     }
 }
开发者ID:cskilbeck,项目名称:Project1,代码行数:28,代码来源:BitmapFont.cs

示例14: Blend

    //0 - A over B, 1 - B over A, 2 - Multiply
    public static Texture2D Blend(Texture2D a, Texture2D b, int mode)
    {
        IntPairClass resA = new IntPairClass(a);
        IntPairClass resB = new IntPairClass(b);
        IntPairClass res = new IntPairClass();
        res.SetFromMinimum(resA, resB);

        Color[] originalColorsA = a.GetPixels(0, 0, res.value01, res.value02);
        Color[] originalColorsB = b.GetPixels(0, 0, res.value01, res.value02);
        Color[] resultColors = new Color[originalColorsA.Length];

        for(int i = 0; i < resultColors.Length; i++)
        {
            Color aColor = originalColorsA[i];
            Color bColor = originalColorsB[i];
            Color r = new Color();
            if(mode == 0 || mode == 1)
            {
                float restForB = GetMin(bColor.a, 1 - aColor.a);
                r = new Color(GetMiddleValue(aColor.r, bColor.r, aColor.a, restForB), GetMiddleValue(aColor.g, bColor.g, aColor.a, restForB), GetMiddleValue(aColor.b, bColor.b, aColor.a, restForB), aColor.a + restForB);
            }
            else if(mode == 2)
            {
                r = new Color(aColor.r * bColor.r, aColor.g * bColor.g, aColor.b * bColor.b, aColor.a * bColor.a);
            }
            resultColors[i] = r;
        }

        Texture2D toReturn = new Texture2D(a.width, a.height, TextureFormat.RGBA32, true);
        toReturn.SetPixels(0, 0, a.width, a.height, resultColors);
        toReturn.Apply(true);
        return toReturn;
    }
开发者ID:Angel07,项目名称:Node_Editor,代码行数:34,代码来源:ImageProcessorTypes.cs

示例15: changeSpritesColour

 public void changeSpritesColour()
 {
     texWidth = 32;
     texHeight = 32;
     newTexture = new Texture2D(texWidth, texHeight, TextureFormat.ARGB32, false);
     newTexture.SetPixels(spriteParent.sprite.texture.GetPixels());
     cArray = newTexture.GetPixels();
     int y = 0;
     while(y < texHeight)
     {
         int x = 0;
         while(x < texWidth)
         {
             if(newTexture.GetPixel(x, y) == skinColourBase)
                 newTexture.SetPixel(x, y, skinColour);
             if(newTexture.GetPixel(x, y) == hairColourBase)
                 newTexture.SetPixel(x, y, hairColour);
             if(newTexture.GetPixel(x, y) == eyeColourBase)
                 newTexture.SetPixel(x, y, eyeColour);
             if(newTexture.GetPixel(x, y) == shoeColourBase)
                 newTexture.SetPixel(x, y, shoeColour);
             if(newTexture.GetPixel(x, y) == shirtColourBase)
                 newTexture.SetPixel(x, y, shirtColour);
             if(newTexture.GetPixel(x, y) == pantsColourBase)
                 newTexture.SetPixel(x, y, pantsColour);
             x++;
         }
         y++;
     }
     newTexture.wrapMode = TextureWrapMode.Clamp;
     newTexture.filterMode = FilterMode.Point;
     newTexture.Apply();
     spriteParent.sprite = Sprite.Create(newTexture, new Rect(0, 0, texWidth, texHeight), new Vector2(0.5f, 0.5f), 16);
 }
开发者ID:ZyronAlex,项目名称:Unity-Top-Down-2D-RPG-Tutorial,代码行数:34,代码来源:Entity.cs


注:本文中的UnityEngine.Texture2D.GetPixels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。