public static bool LOAD(BinaryReader reader) { string text = reader.ReadString(); GameObject gameObject = GameObject.Find(text); if (gameObject == null) { int length = text.IndexOf("/", 1); string name = text.Substring(0, length); GameObject gameObject2 = GameObject.Find(name); if (gameObject2 != null) { int startIndex = text.LastIndexOf("/") + 1; string b = text.Substring(startIndex); SaveTarget[] componentsInChildren = gameObject2.GetComponentsInChildren <SaveTarget>(true); for (int i = 0; i < componentsInChildren.Length; i++) { SaveTarget saveTarget = componentsInChildren[i]; if (saveTarget.name == b) { gameObject = saveTarget.gameObject; break; } } } } if (gameObject == null) { return(false); } SaveTarget saveTarget2 = gameObject.GetComponent <SaveTarget>(); if (saveTarget2 == null) { saveTarget2 = gameObject.AddComponent <SaveTarget>(); } saveTarget2.Load(reader); return(true); }
void ProcessStartAttributeCommon(ref string prefix, string localName, string ns, object nameObj, object nsObj) { // dummy prefix is created here, while the caller // still uses empty string as the prefix there. if (prefix.Length == 0 && ns.Length > 0) { prefix = LookupPrefix(ns); // Not only null but also ""; when the returned // string is empty, then it still needs a dummy // prefix, since default namespace does not // apply to attribute if (String.IsNullOrEmpty(prefix)) { prefix = CreateNewPrefix(); } } else if (prefix.Length > 0 && ns.Length == 0) { switch (prefix) { case "xml": nsObj = ns = XmlNamespace; break; case "xmlns": nsObj = ns = XmlnsNamespace; break; default: throw new ArgumentException("Cannot use prefix with an empty namespace."); } } // here we omit such cases that it is used for writing // namespace-less xml, unlike XmlTextWriter. if (prefix == "xmlns" && ns != XmlnsNamespace) { throw new ArgumentException(String.Format("The 'xmlns' attribute is bound to the reserved namespace '{0}'", XmlnsNamespace)); } CheckStateForAttribute(); state = WriteState.Attribute; save_target = SaveTarget.None; switch (prefix) { case "xml": // MS.NET looks to allow other names than // lang and space (e.g. xml:link, xml:hack). ns = XmlNamespace; switch (localName) { case "lang": save_target = SaveTarget.XmlLang; break; case "space": save_target = SaveTarget.XmlSpace; break; } break; case "xmlns": save_target = SaveTarget.Namespaces; break; } current_attr_prefix = prefix; current_attr_name = nameObj; current_attr_ns = nsObj; }
void ProcessStartAttributeCommon (ref string prefix, string localName, string ns, object nameObj, object nsObj) { // dummy prefix is created here, while the caller // still uses empty string as the prefix there. if (prefix.Length == 0 && ns.Length > 0) { prefix = LookupPrefix (ns); // Not only null but also ""; when the returned // string is empty, then it still needs a dummy // prefix, since default namespace does not // apply to attribute if (String.IsNullOrEmpty (prefix)) prefix = CreateNewPrefix (); } else if (prefix.Length > 0 && ns.Length == 0) { switch (prefix) { case "xml": nsObj = ns = XmlNamespace; break; case "xmlns": nsObj = ns = XmlnsNamespace; break; default: throw new ArgumentException ("Cannot use prefix with an empty namespace."); } } // here we omit such cases that it is used for writing // namespace-less xml, unlike XmlTextWriter. if (prefix == "xmlns" && ns != XmlnsNamespace) throw new ArgumentException (String.Format ("The 'xmlns' attribute is bound to the reserved namespace '{0}'", XmlnsNamespace)); CheckStateForAttribute (); state = WriteState.Attribute; save_target = SaveTarget.None; switch (prefix) { case "xml": // MS.NET looks to allow other names than // lang and space (e.g. xml:link, xml:hack). ns = XmlNamespace; switch (localName) { case "lang": save_target = SaveTarget.XmlLang; break; case "space": save_target = SaveTarget.XmlSpace; break; } break; case "xmlns": save_target = SaveTarget.Namespaces; break; } current_attr_prefix = prefix; current_attr_name = nameObj; current_attr_ns = nsObj; }
void Start() { text = GetComponentInChildren <Text> (); displayText = new SaveTarget(this, "displayText", string.Empty); text.text = displayText.Value; }