private static void Load() { if (!loaded) { allCursors = Resources.Load <Texture2D>("Browser/CursorsTexture"); if (!allCursors) { throw new Exception("Failed to find browser allCursors"); } size = allCursors.height; TextAsset textAsset = Resources.Load <TextAsset>("Browser/CursorsText"); string[] array = textAsset.text.Split('\n'); foreach (string text in array) { string[] array2 = text.Split(','); BrowserNative.CursorType key = (BrowserNative.CursorType)Enum.Parse(typeof(BrowserNative.CursorType), array2[0]); CursorInfo cursorInfo = new CursorInfo(); cursorInfo.atlasOffset = int.Parse(array2[1]); cursorInfo.hotspot = new Vector2(int.Parse(array2[2]), int.Parse(array2[3])); CursorInfo value = cursorInfo; mapping[key] = value; } loaded = true; } }
public virtual void SetActiveCursor(BrowserNative.CursorType type) { switch (type) { case BrowserNative.CursorType.Custom: throw new ArgumentException("Use SetCustomCursor to set custom cursors.", "type"); case BrowserNative.CursorType.None: Texture = null; this.cursorChange(); return; } CursorInfo cursorInfo = mapping[type]; Color[] pixels = allCursors.GetPixels(cursorInfo.atlasOffset * size, 0, size, size); Hotspot = cursorInfo.hotspot; normalTexture.SetPixels(pixels); normalTexture.Apply(updateMipmaps: true); Texture = normalTexture; this.cursorChange(); }