37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Cube : MonoBehaviour
|
|
{
|
|
public MeshRenderer Renderer;
|
|
private Vector3 transformation = new Vector3(5, 1, 5);
|
|
private Vector3 scaling = Vector3.one * 2.5f;
|
|
Color color = new Color(1f, 0.1f, 0.1f, 1f);
|
|
Color glowColor = new Color(1f, 0.3f, 0.1f, 1f);
|
|
float glowFactor = 10f;
|
|
float rotateX = 80.0f;
|
|
float rotateY = -120.0f;
|
|
float rotateZ = 180.0f;
|
|
|
|
void Start()
|
|
{
|
|
transform.position = transformation;
|
|
transform.localScale = scaling;
|
|
|
|
Material material = Renderer.material;
|
|
material.color = color;
|
|
material.EnableKeyword("_EMISSION");
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
// Rotation
|
|
transform.Rotate(rotateX * Time.deltaTime, rotateY * Time.deltaTime, rotateZ * Time.deltaTime);
|
|
|
|
// Pulsing Glow
|
|
float pulse = 0.5f + 0.5f * Mathf.Sin(Time.time * 5f);
|
|
Renderer.material.SetColor("_EmissionColor", glowColor * glowFactor * pulse);
|
|
}
|
|
}
|