高亮时屏蔽贴图
This commit is contained in:
parent
01b66de62f
commit
0927ff6379
@ -14,6 +14,7 @@ public class ObjectColorToggle : MonoBehaviour
|
|||||||
public Color isOffColor = new Color(255 / 255f, 255 / 255f, 255 / 255f);
|
public Color isOffColor = new Color(255 / 255f, 255 / 255f, 255 / 255f);
|
||||||
public Color isHoverColor = new Color(185f / 255f, 255 / 255f, 215 / 255f);
|
public Color isHoverColor = new Color(185f / 255f, 255 / 255f, 215 / 255f);
|
||||||
MeshRenderer mesh;
|
MeshRenderer mesh;
|
||||||
|
private Texture2D savedTexture;
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
mesh = gameObject.GetComponent<MeshRenderer>();
|
mesh = gameObject.GetComponent<MeshRenderer>();
|
||||||
@ -26,14 +27,19 @@ public class ObjectColorToggle : MonoBehaviour
|
|||||||
{
|
{
|
||||||
case State.On:
|
case State.On:
|
||||||
isOnColor.a = alpha;
|
isOnColor.a = alpha;
|
||||||
|
savedTexture = mesh.material.mainTexture as Texture2D;
|
||||||
|
mesh.material.mainTexture = null;
|
||||||
mesh.material.color = isOnColor;
|
mesh.material.color = isOnColor;
|
||||||
break;
|
break;
|
||||||
case State.Off:
|
case State.Off:
|
||||||
isOffColor.a = alpha;
|
isOffColor.a = alpha;
|
||||||
|
mesh.material.mainTexture = savedTexture;
|
||||||
mesh.material.color = isOffColor;
|
mesh.material.color = isOffColor;
|
||||||
break;
|
break;
|
||||||
case State.Hover:
|
case State.Hover:
|
||||||
isHoverColor.a = alpha;
|
isHoverColor.a = alpha;
|
||||||
|
savedTexture = mesh.material.mainTexture as Texture2D;
|
||||||
|
mesh.material.mainTexture = null;
|
||||||
mesh.material.color = isHoverColor;
|
mesh.material.color = isHoverColor;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -56,5 +62,4 @@ public class ObjectColorToggle : MonoBehaviour
|
|||||||
SetColor(State.Off);
|
SetColor(State.Off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user