Chavales, os traigo esta pequeña maravilla procedente de uno de los hilos del foro oficial de Unity3D.
Es un efecto para añadir un gradiente de color a vuestros paneles, imágenes y textos, hechos en UnityGUI (4.6x - 5.0). Un must-have en toda regla.
El mismo autor también ha hecho un efecto para usar
blending. Podéis encontrar más información aquí:
http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-1925105 (http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-1925105)
/*
uGui-Effect-Tool
Copyright (c) 2015 WestHillApps (Hironari Nishioka)
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.UI;
namespace UiEffect
{
[AddComponentMenu ("UI/Effects/Gradient Color")]
[RequireComponent (typeof (Graphic))]
public class GradientColor : BaseVertexEffect
{
public enum DIRECTION
{
Vertical,
Horizontal,
Both,
}
public DIRECTION direction = DIRECTION.Both;
public Color colorTop = Color.white;
public Color colorBottom = Color.black;
public Color colorLeft = Color.red;
public Color colorRight = Color.blue;
Graphic graphic;
public override void ModifyVertices (List<UIVertex> vList)
{
if (IsActive () == false || vList == null || vList.Count == 0) {
return;
}
float topX = 0f, topY = 0f, bottomX = 0f, bottomY = 0f;
foreach (var vertex in vList) {
topX = Mathf.Max (topX, vertex.position.x);
topY = Mathf.Max (topY, vertex.position.y);
bottomX = Mathf.Min (bottomX, vertex.position.x);
bottomY = Mathf.Min (bottomY, vertex.position.y);
}
float width = topX - bottomX;
float height = topY - bottomY;
UIVertex tempVertex = vList[0];
for (int i = 0; i < vList.Count; i++) {
tempVertex = vList;
byte orgAlpha = tempVertex.color.a;
Color colorOrg = tempVertex.color;
Color colorV = Color.Lerp (colorBottom, colorTop, (tempVertex.position.y - bottomY) / height);
Color colorH = Color.Lerp (colorLeft, colorRight, (tempVertex.position.x - bottomX) / width);
switch (direction) {
case DIRECTION.Both:
tempVertex.color = colorOrg * colorV * colorH;
break;
case DIRECTION.Vertical:
tempVertex.color = colorOrg * colorV;
break;
case DIRECTION.Horizontal:
tempVertex.color = colorOrg * colorH;
break;
}
tempVertex.color.a = orgAlpha;
vList = tempVertex;
}
}
/// <summary>
/// Refresh Gradient Color on playing.
/// </summary>
public void Refresh ()
{
if (graphic == null) {
graphic = GetComponent<Graphic> ();
}
if (graphic != null) {
graphic.SetVerticesDirty ();
}
}
}
}
Hola, es posible con esos scripts utilizar blending del estilo de los q tiene photoshop (add, screen, multiply, etc) en imagemes o paneles en el UICanvas?
Gracias.