public override void gaxb_load(XmlReader reader, object _parent, Hashtable args) { base.gaxb_load(reader, _parent, args); if (reader == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PUColor)) { gaxb_addToParent(); } //xmlns = reader.GetAttribute("xmlns"); string attr; attr = reader.GetAttribute("color"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr != null) { color = new Color().PUParse(attr); } }
public override void gaxb_final(TB.TBXMLElement element, object _parent, Hashtable args) { base.gaxb_final(element, _parent, args); if (element != null) { style = element.GetAttribute("style"); string s = element.GetAttribute("value"); if (s != null) { value = PlanetUnityStyle.ReplaceStyleTags(PlanetUnityOverride.processString(this, s)); } s = element.GetAttribute("autoreload"); if (s != null) { autoreload = bool.Parse(s); } } if (style != null) { string classString = "MarkdownStyle" + style; Type entityClass = Type.GetType(classString, true); mdStyle = (Activator.CreateInstance(entityClass)) as MarkdownStyle; } else { mdStyle = new MarkdownStyleGeneric(); } mdStyle.markdownEntity = this; }
static public Font GetFont(string s) { if (s == null) { return(null); } if (fonts.ContainsKey(s)) { return(fonts [s]); } Font font = null; if (s.Equals("Arial")) { font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"); } if (font == null) { font = (Font)PlanetUnityOverride.LoadResource(typeof(Font), s); } if (font == null) { return(null); } fonts [s] = font; return(font); }
public override void gaxb_init() { gameObject = new GameObject("<Movie/>", typeof(RectTransform)); canvasRenderer = gameObject.AddComponent <CanvasRenderer> (); image = gameObject.AddComponent <RawImage> (); if (color != null) { image.color = color.Value; } if (resourcePath != null) { // Why, oh why are movie textures not supported in iOS? #if (UNITY_IOS || UNITY_ANDROID || UNITY_WEBGL || UNITY_TVOS) #else // Set texture MovieTexture tex = (MovieTexture)PlanetUnityOverride.LoadResource(typeof(MovieTexture), resourcePath); if (tex != null) { image.texture = tex; tex.Stop(); tex.Play(); tex.loop = looping; } #endif } }
public override void gaxb_loadattrs() { base.gaxb_loadattrs(); string attr; attr = raw_key; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { key = unescape(attr); } attr = raw_value; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { value = unescape(attr); } }
public override void gaxb_load(XmlReader reader, object _parent, Hashtable args) { base.gaxb_load(reader, _parent, args); if (reader == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PUNotification)) { gaxb_addToParent(); } //xmlns = reader.GetAttribute("xmlns"); string attr; attr = reader.GetAttribute("name"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr != null) { name = unescape(attr); } }
public override void gaxb_loadattrs() { base.gaxb_loadattrs(); string attr; attr = raw_onTouchUp; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { onTouchUp = unescape(attr); } attr = raw_pressedColor; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { pressedColor = new Color().PUParse(attr); } }
static public string Translate(string key, string code) { VerifyLanguageCode(code); Dictionary <string, string> languageDict; if (!allLanguages.TryGetValue(code, out languageDict)) { if (code.Equals("en")) { return(key); } return(Translate(key, "en")); } try{ string value = languageDict[key]; if (value == null) { if (code.Equals("en")) { return(key); } return(Translate(key, "en")); } return(PlanetUnityOverride.appProcessString(value)); }catch { //Debug.Log ("Language key " + key + " does not exist"); } return(PlanetUnityOverride.appProcessString(key)); }
static public string GetTextFile(string s) { if (s == null) { return(null); } if (stringFiles.ContainsKey(s)) { return(stringFiles [s]); } TextAsset stringData = (TextAsset)PlanetUnityOverride.LoadResource(typeof(TextAsset), s); if (stringData == null) { return(null); } string t = stringData.text; #if UNITY_EDITOR #else stringFiles [s] = t; #endif return(t); }
public override void gaxb_loadattrs() { base.gaxb_loadattrs(); string attr; attr = raw__class; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { _class = unescape(attr); } attr = raw_singleton; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "false"; } if (attr != null) { singleton = bool.Parse(attr); } }
public override void gaxb_loadattrs() { base.gaxb_loadattrs(); string attr; attr = raw_heuristic; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "RectBottomLeftRule"; } if (attr != null) { heuristic = (PlanetUnity2.GridTableHeuristic)Enum.Parse(typeof(PlanetUnity2.GridTableHeuristic), attr); } attr = raw_expandToFill; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "true"; } if (attr != null) { expandToFill = bool.Parse(attr); } }
public override void gaxb_load(TBXMLElement element, object _parent, Hashtable args) { base.gaxb_load(element, _parent, args); if (element == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PUSwitcher)) { gaxb_addToParent(); } //xmlns = element.GetAttribute("xmlns"); string attr; attr = element.GetAttribute("currentIndex"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "0"; } if (attr != null) { currentIndex = (int)float.Parse(attr); } }
public override void gaxb_load(TBXMLElement element, object _parent, Hashtable args) { base.gaxb_load(element, _parent, args); if (element == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PUPrefab)) { gaxb_addToParent(); } //xmlns = element.GetAttribute("xmlns"); string attr; attr = element.GetAttribute("name"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr != null) { name = unescape(attr); } }
public override void gaxb_loadattrs() { base.gaxb_loadattrs(); string attr; attr = raw_contentSize; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "0,0"; } if (attr != null) { contentSize = new Vector2().PUParse(attr); } attr = raw_mode; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "FitInParent"; } if (attr != null) { mode = (PlanetUnity2.AspectFitMode)Enum.Parse(typeof(PlanetUnity2.AspectFitMode), attr); } }
public override void gaxb_loadattrs() { base.gaxb_loadattrs(); string attr; attr = raw_cellSize; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { cellSize = new Vector2().PUParse(attr); } attr = raw_headerSize; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "0,0"; } if (attr != null) { headerSize = new Vector2().PUParse(attr); } attr = raw_asynchronous; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "true"; } if (attr != null) { asynchronous = bool.Parse(attr); } attr = raw_expandCellWidth; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "true"; } if (attr != null) { expandCellWidth = bool.Parse(attr); } }
public override void gaxb_load(TBXMLElement element, object _parent, Hashtable args) { base.gaxb_load(element, _parent, args); if (element == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PUVerticalLayoutGroup)) { gaxb_addToParent(); } //xmlns = element.GetAttribute("xmlns"); string attr; attr = element.GetAttribute("spacing"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "0"; } if (attr != null) { spacing = float.Parse(attr); } attr = element.GetAttribute("padding"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "0,0,0,0"; } if (attr != null) { padding = new Vector4().PUParse(attr); } attr = element.GetAttribute("childAlignment"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr != null) { childAlignment = (PlanetUnity2.GridLayoutChildAlignment)Enum.Parse(typeof(PlanetUnity2.GridLayoutChildAlignment), attr); } }
public override void gaxb_load(XmlReader reader, object _parent, Hashtable args) { base.gaxb_load(reader, _parent, args); if (reader == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PUSimpleTable)) { gaxb_addToParent(); } //xmlns = reader.GetAttribute("xmlns"); string attr; attr = reader.GetAttribute("cellSize"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr != null) { cellSize = new Vector2().PUParse(attr); } attr = reader.GetAttribute("headerSize"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "0,0"; } if (attr != null) { headerSize = new Vector2().PUParse(attr); } attr = reader.GetAttribute("asynchronous"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "true"; } if (attr != null) { asynchronous = bool.Parse(attr); } }
static public AudioClip GetAudioClip(string s) { if (s == null) { return(null); } return((AudioClip)PlanetUnityOverride.LoadResource(typeof(AudioClip), s)); }
static public T GetAsset <T>(string s) { if (s == null) { return(default(T)); } return((T)PlanetUnityOverride.LoadResource(typeof(T), s)); }
private static string evaluateString(string evalListString, object o, float multiplier, Func <decimal, decimal> appOverride = null) { var parts = Regex.Split(evalListString, ",(?![^(]*\\))"); RectTransform rectTransform = null; mathParser.LocalVariables ["dpi"] = Convert.ToDecimal(PlanetUnityOverride.screenDPI()); mathParser.LocalVariables ["screenW"] = Convert.ToDecimal(Screen.width / multiplier); mathParser.LocalVariables ["screenH"] = Convert.ToDecimal(Screen.height / multiplier); #if UNITY_IOS mathParser.LocalVariables ["statusBarHeight"] = Convert.ToDecimal((0.13f * PlanetUnityOverride.screenDPI()) / multiplier); #else mathParser.LocalVariables ["statusBarHeight"] = 0; #endif GameObject parentAsGameObject = o as GameObject; PUGameObject parentAsPUGameObject = o as PUGameObject; if (parentAsGameObject != null) { rectTransform = parentAsGameObject.GetComponent <RectTransform> (); } else if (parentAsPUGameObject != null) { rectTransform = parentAsPUGameObject.gameObject.GetComponent <RectTransform> (); } if (rectTransform) { // Work around for unity stretching canvas bug if (o is PUCanvas && (int)rectTransform.rect.width == 100 && (int)rectTransform.rect.height == 100) { mathParser.LocalVariables ["w"] = Convert.ToDecimal(Screen.width / multiplier); mathParser.LocalVariables ["h"] = Convert.ToDecimal(Screen.height / multiplier); } else { mathParser.LocalVariables ["w"] = Convert.ToDecimal(rectTransform.rect.width / multiplier); mathParser.LocalVariables ["h"] = Convert.ToDecimal(rectTransform.rect.height / multiplier); } } evalStringBuilder.Length = 0; foreach (string part in parts) { decimal result = (mathParser.Parse(part) * (decimal)multiplier); if (appOverride != null) { result = appOverride(result); } evalStringBuilder.AppendFormat("{0},", result); } evalStringBuilder.Length = evalStringBuilder.Length - 1; return(evalStringBuilder.ToString()); }
static public Texture2D GetTexture(string s) { if (s == null) { return(null); } if (s.StartsWith("/") && (s.EndsWith(".png") || s.EndsWith(".jpg"))) { if (File.Exists(s)) { Texture2D fileImage = new Texture2D(512, 512, TextureFormat.ARGB32, false); fileImage.LoadImage(File.ReadAllBytes(s)); fileImage.filterMode = FilterMode.Bilinear; fileImage.wrapMode = TextureWrapMode.Clamp; return(fileImage); } } TextAsset fileData = (TextAsset)PlanetUnityOverride.LoadResource(typeof(TextAsset), s); if (fileData != null) { Texture2D tex = new Texture2D(2, 2, TextureFormat.ARGB32, false); tex.LoadImage(fileData.bytes); tex.filterMode = FilterMode.Bilinear; tex.wrapMode = TextureWrapMode.Clamp; return(tex); } Texture2D t = (Texture2D)PlanetUnityOverride.LoadResource(typeof(Texture2D), s); if (t == null) { #if (UNITY_WEBPLAYER == false && UNITY_WEBGL == false) if (s.EndsWith(".png") || s.EndsWith(".jpg")) { string filePath = Application.streamingAssetsPath + "/" + s; if (File.Exists(filePath)) { t = new Texture2D(2, 2, TextureFormat.ARGB32, false); t.LoadImage(File.ReadAllBytes(filePath)); t.filterMode = FilterMode.Bilinear; t.wrapMode = TextureWrapMode.Clamp; } } #endif if (t == null) { Debug.Log("Unable to load streaming asset: " + Application.streamingAssetsPath + "/" + s); return(null); } } t.filterMode = FilterMode.Bilinear; return(t); }
public override void gaxb_loadattrs() { base.gaxb_loadattrs(); string attr; attr = raw_pressedResourcePath; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { pressedResourcePath = unescape(attr); } attr = raw_highlightedResourcePath; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { highlightedResourcePath = unescape(attr); } attr = raw_disabledResourcePath; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { disabledResourcePath = unescape(attr); } attr = raw_onTouchUp; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { onTouchUp = unescape(attr); } attr = raw_onTouchDown; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr != null) { onTouchDown = unescape(attr); } }
public void ReloadCanvas() { CheckForEventSystem(); LoadCanvasXML(PlanetUnityOverride.xmlFromPath(xmlPath)); if (scaleAutomatically) { SetReferenceResolution(referenceResolution.x, referenceResolution.y); } }
public static string processString(object cur, object o, string s) { if (s == null) { return(null); } #if USE_LAURETTE s = s.Replace("@LANGUAGE", Localizations.GetLanguageCode()); #endif s = s.Replace("\\n", "\n"); if (s.Equals("nan")) { return("0"); } if (s.StartsWith("@localization(")) { #if USE_LAURETTE string evalListString = s.Substring(14, s.Length - 15); s = Localizations.TranslateKey(evalListString); #endif } else if (s.StartsWith("@eval(")) { string evalListString = s.Substring(6, s.Length - 7); s = evaluateString(evalListString, o, 1.0f); PUGameObject current = cur as PUGameObject; if (current != null) { foreach (var token in mathParser.usedTokens) { current.Canvas.GetVariable(token).AddListener(current); } } } else if (s.StartsWith("@dpi(")) { string evalListString = s.Substring(5, s.Length - 6); s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI()); } else if (s.StartsWith("@app1(")) { string evalListString = s.Substring(6, s.Length - 7); s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI(), PlanetUnityOverride.app1); } return(PlanetUnityOverride.appProcessString(s)); }
public override void gaxb_load(TBXMLElement element, object _parent, Hashtable args) { base.gaxb_load(element, _parent, args); if (element == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PURawImage)) { gaxb_addToParent(); } //xmlns = element.GetAttribute("xmlns"); string attr; attr = element.GetAttribute("resourcePath"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr != null) { resourcePath = unescape(attr); } attr = element.GetAttribute("color"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr != null) { color = new Color().PUParse(attr); } attr = element.GetAttribute("uvRect"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr != null) { uvRect = new Vector4().PUParse(attr); } }
public override void gaxb_load(XmlReader reader, object _parent, Hashtable args) { base.gaxb_load(reader, _parent, args); if(reader == null && _parent == null) return; parent = _parent; if(this.GetType() == typeof( PUGridLayoutGroup )) { gaxb_addToParent(); } //xmlns = reader.GetAttribute("xmlns"); string attr; attr = reader.GetAttribute("cellSize"); if(attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if(attr == null) { attr = "100,100"; } if(attr != null) { cellSize = new Vector2().PUParse(attr); } attr = reader.GetAttribute("spacing"); if(attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if(attr == null) { attr = "0,0"; } if(attr != null) { spacing = new Vector2().PUParse(attr); } attr = reader.GetAttribute("startCorner"); if(attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if(attr != null) { startCorner = (PlanetUnity2.GridLayoutStartCorner)Enum.Parse(typeof(PlanetUnity2.GridLayoutStartCorner), attr); } attr = reader.GetAttribute("startAxis"); if(attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if(attr != null) { startAxis = (PlanetUnity2.GridLayoutStartAxis)Enum.Parse(typeof(PlanetUnity2.GridLayoutStartAxis), attr); } attr = reader.GetAttribute("childAlignment"); if(attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if(attr != null) { childAlignment = (PlanetUnity2.GridLayoutChildAlignment)Enum.Parse(typeof(PlanetUnity2.GridLayoutChildAlignment), attr); } attr = reader.GetAttribute("fixedRows"); if(attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if(attr != null) { fixedRows = (int)float.Parse(attr); } attr = reader.GetAttribute("fixedColumns"); if(attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if(attr != null) { fixedColumns = (int)float.Parse(attr); } }
public override void gaxb_load(TBXMLElement element, object _parent, Hashtable args) { base.gaxb_load(element, _parent, args); if (element == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PUAspectFit)) { gaxb_addToParent(); } //xmlns = element.GetAttribute("xmlns"); string attr; attr = element.GetAttribute("contentSize"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "0,0"; } if (attr != null) { contentSize = new Vector2().PUParse(attr); } attr = element.GetAttribute("mode"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "FitInParent"; } if (attr != null) { mode = (PlanetUnity2.AspectFitMode)Enum.Parse(typeof(PlanetUnity2.AspectFitMode), attr); } }
public override void gaxb_loadattrs() { base.gaxb_loadattrs(); string attr; attr = raw_renderMode; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "ScreenSpaceOverlay"; } if (attr != null) { renderMode = (PlanetUnity2.CanvasRenderMode)Enum.Parse(typeof(PlanetUnity2.CanvasRenderMode), attr); } attr = raw_pixelPerfect; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "false"; } if (attr != null) { pixelPerfect = bool.Parse(attr); } attr = raw_planeDistance; if (attr != null) { attr = PlanetUnityOverride.processString(this, parent, attr); } if (attr == null) { attr = "100"; } if (attr != null) { planeDistance = float.Parse(attr); } }
public override void gaxb_load(TBXMLElement element, object _parent, Hashtable args) { base.gaxb_load(element, _parent, args); if (element == null && _parent == null) { return; } parent = _parent; if (this.GetType() == typeof(PUGridTable)) { gaxb_addToParent(); } //xmlns = element.GetAttribute("xmlns"); string attr; attr = element.GetAttribute("heuristic"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "RectBottomLeftRule"; } if (attr != null) { heuristic = (PlanetUnity2.GridTableHeuristic)Enum.Parse(typeof(PlanetUnity2.GridTableHeuristic), attr); } attr = element.GetAttribute("expandToFill"); if (attr != null) { attr = PlanetUnityOverride.processString(_parent, attr); } if (attr == null) { attr = "true"; } if (attr != null) { expandToFill = bool.Parse(attr); } }
static public string GetTextFileNoCache(string s) { if (s == null) { return(null); } TextAsset stringData = (TextAsset)PlanetUnityOverride.LoadResource(typeof(TextAsset), s); if (stringData == null) { return(null); } return(stringData.text); }