I am trying to make a clock using 6 textures on 6 planes one each for the hh mm ss, I am using uv animator to shift a tiled image around, the tiled image in this instance being the last tile is the seconds counter, has 10 tiles from 0-9
my script works but I am taking the time as a string and I need it split it into 2 integers, one for each of the “ss” textures.
I know I can do this with guitext but I want to use my images.
I think this something like what I need, I need to convert the hh, mm, and ss, into single numbers to insert in the vector position
import System;
var date = DateTime.Now;
InvokeRepeating("Start", 2, 0.10);
function Start () {
var TheHours = System.DateTime.Now.ToString("HH");
var TheMinutes = System.DateTime.Now.ToString("MM");
var TheSeconds = System.DateTime.Now.get_Second();
var TheMonth = System.DateTime.Now.get_Month();
var TheDay = System.DateTime.Now.get_Day();
var TheYear = System.DateTime.Now.get_Year();
//guiText.text = ""TheSeconds;
var uvAnimationTileX = 10; //columns per sheet.
var uvAnimationTileY = 1; //rows per sheet
.
// Calculate index
// This works but calls the seconds as an integer,
//I really need to extract is as a string and split it into 2 integers like this
//var index : int = minutesa; //minutesa is the first digit in TheSeconds script
var index : int = TheSeconds; //Time.time * framesPerSecond;
// Size of every tile
var size = Vector2 (1.0 / uvAnimationTileX, 1.0 / uvAnimationTileY);
// split into horizontal and vertical index
var uIndex = index % uvAnimationTileX;
var vIndex = index / uvAnimationTileX;
// build offset of the tile size
// v coordinate is the bottom of the image in opengl so we need to invert.
var offset = Vector2 (uIndex * size.x, 1.0 - size.y - vIndex * size.y);
renderer.material.SetTextureOffset ("_MainTex", offset);
renderer.material.SetTextureScale ("_MainTex", size);
}