GKCSVParser(string fileName) { _sourceCsv = System.IO.File.ReadAllText(fileName, GK.GetEncoding(fileName, out _readIndex)); if (_sourceCsv.Contains("\r\n")) { _sourceCsv = _sourceCsv.Replace("\r\n", "\n"); } _sourceCsv = _sourceCsv.TrimEnd('\n'); }
public object[] TakeScreenshot() { Debug.Log(sourceRect); Texture2D texture = new Texture2D(_width, _height, TextureFormat.RGB24, false); texture.ReadPixels(sourceRect, 0, 0, false); GK.SaveTextureToFile(texture, String.Format("{0}/Screenshot-{1:yyMMddHHmmssfff}.png", Application.dataPath, DateTime.Now)); return(parameters); }
static public GameObject GetOrAddGameObject(GameObject o, string name) { if (!o) { return(null); } var f = o.transform.Find(name); if (f) { return(f.gameObject); } var c = new GameObject(name); c.transform.parent = o.transform; GK.ResetLocalTransform(c); return(c); }
static public void DestroyAllChildren2D(RectTransform t) { if (t.childCount == 0) { return; } var c = new RectTransform[t.childCount]; int i = 0; foreach (RectTransform ct in t) { c[i] = ct; i++; } foreach (var p in c) { GK.Destroy(p.gameObject); } }
static public void FindControls <T>(GameObject obj, ref T controls) where T : new() { if (controls == null) { controls = new T(); } var type = controls.GetType(); var fields = type.GetFields(); foreach (var f in fields) { var attrs = f.GetCustomAttributes(typeof(System.NonSerializedAttribute), false); if (attrs.Length != 0) { continue; } f.GetCustomAttributes(typeof(System.NonSerializedAttribute), false); var w = GK.FindChild(obj, f.Name, true); if (w == null) { Debug.LogError("Cannot find widget [" + f.Name + "] in " + GK.Fullname(obj)); f.SetValue(controls, null); continue; } if (f.FieldType == typeof(GameObject)) { f.SetValue(controls, w); } else if (f.FieldType.IsSubclassOf(typeof(Component))) { var c = w.GetComponent(f.FieldType); f.SetValue(controls, c); } } }