public void SetParentTransform(Transform ts) { // ensure that the parent transform is if (ts == null) { // fix when parent tranform has been destroyed after create if (this.set_parent_transform) { Destroy(); } return; } if (this.gameObject != null) { this.gameObject.transform.parent = ts; } //这里会重置init_position等数据导致位置不对 //SetPosition(Vector3.zero); //SetRotation(Vector3.zero); //SetScale(Vector3.one); this.parent_transform = ts; this.set_parent_transform = true; }
public void SetLayer(int layer) { if (layer == 0) { return; } this.layer = layer; if (children != null) { for (PListNode n = children.next; n != children; n = n.next) { IRenderObject child = (IRenderObject)n; if (child.layer == 0) { child.layer = layer; } } } if (this.gameObject != null) { SetLayerRecursively(this.gameObject); } }
public void RemoveInstance(IRenderObject obj) { if (!this.insts.Remove(obj)) { return; } IResourceFactory.Cookie cookie = factory.GetCookie(name); --cookie.count; if (cookie.count <= 0) { cookie.create_time = Time.realtimeSinceStartup; } /* 由factory去决定什么时候Destroy之~ */ if (this.insts.Count == 0) { idle_time = Time.realtimeSinceStartup; if (factory != null) { factory.DestroyResource(this); } else { Destroy(); } } }
public void Destroy() { if (destroy) { return; } try { if (children != null) { for (PListNode n = children.next, next; n != children; n = next) { next = n.next; IRenderObject child = (IRenderObject)n; if (child != null) { child.SetParent(null); } } children = null; } if (ctrls != null) { foreach (IController c in ctrls.Values) { if (c != null) { c.Destroy(); } } ctrls.Clear(); ctrls = null; } if (timer != null) { timer.Clear(); } this.SetParent(null); this.OnDestroy(); if (this.owner != null) { this.owner.RemoveInstance(this); this.owner = null; } } catch (Exception e) { LOG.LogError(e.ToString(), this.gameObject); } destroy = true; }
public void SetParent(IRenderObject parent) { if (this.parent != null) { this.parent.RemoveChild(this); } this.parent = parent; if (this.parent != null) { this.parent.AddChild(this); } }
public T CreateEmptyInstance <T>(IRenderObject parent, params object[] args) where T : IRenderObject { if (empty == null) { empty = new IEmptyResource(this); Cookie cookie = GetCookie(empty.name); ++cookie.create; empty_parent = empty.CreateInstance <IEmptyObject>(null); loading.Add("empty", empty); } return(empty.CreateInstance <T>(parent, args)); }
public void RemoveChild(IRenderObject child) { if (this.children == null) { return; } children.Remove(child); if (this.gameObject != null && child.gameObject != null && child.gameObject.transform.parent == this.gameObject.transform) { child.gameObject.transform.parent = null; } }
public void AddChild(IRenderObject child) { if (children == null) { children = new PList(); children.Init(); } children.AddTail(child); if (this.gameObject != null && child.gameObject != null) { child.gameObject.transform.parent = this.gameObject.transform; } }
public void Create() { if (destroy) { return; } this.OnCreate(); complete = true; if (this.parent != null) { if (this.gameObject != null && this.parent.gameObject != null) { this.gameObject.transform.parent = this.parent.gameObject.transform; } // Inherit the parent's layer, when child doesn't assign a layer. if (this.layer == 0 && this.parent.layer != 0) { this.layer = this.parent.layer; } } ApplyInitPosition(); if (children != null) { for (PListNode n = children.next; n != children; n = n.next) { IRenderObject child = (IRenderObject)n; if (this.gameObject != null && child.gameObject != null) { child.gameObject.transform.parent = this.gameObject.transform; child.ApplyInitPosition(); } } } SetLayer(this.layer); if (!this.visible) { SetVisible(this.visible); } if (!this.skinvisible) { SetSkinVisible(this.skinvisible); } }
public T CreateInstance <T>(string filename, IRenderObject parent, bool unload, params object[] args) where T : IRenderObject { IRenderResource resource; filename = filename.ToLower(); if (CMisc.isLegalNumber(filename)) { LOG.LogError(Localization.Format("INVALID_LOAD_PATH", filename)); } if (parent != null && parent.GetOwner() != null) { if (parent.GetOwner().unload_asset) { unload = parent.GetOwner().unload_asset; } } if (idle.TryGetValue(filename, out resource)) { idle.Remove(filename); if (resource.complete) { complete.Add(filename, resource); } else { loading.Add(filename, resource); } //LOG.Debug( "***** get resource {0} from idle, linger {1}s", filename, Time.realtimeSinceStartup - resource.idle_time ); } else if (!loading.TryGetValue(filename, out resource)) { if (!complete.TryGetValue(filename, out resource)) { resource = new IRenderResource(filename, this); resource.unload_asset = unload; loading.Add(resource.name, resource); Cookie cookie = GetCookie(filename); ++cookie.create; } } if (resource == null) { return(null); } return(resource.CreateInstance <T>(parent, args)); }
public T CreateInstance <T>(IRenderObject parent, params object[] args) where T : IRenderObject { T inst = AllocInstance <T>(args); inst.SetOwner(this); inst.SetParent(parent); if (this.complete) { inst.Create(); } IResourceFactory.Cookie cookie = factory.GetCookie(name); ++cookie.total; ++cookie.count; idle_time = 0; this.insts.Add(inst); return(inst); }
public void Update() { if (destroy) { return; } if (ctrls != null) { foreach (var v in ctrls.Values) { IController c = v as IController; if (c != null && c.enabled) { c.Update(); } } } OnUpdate(); if (children != null) { for (PListNode n = children.next, next; n != children; n = next) { next = n.next; IRenderObject child = (IRenderObject)n; if (child != null) { child.Update(); } } } if (timer != null) { timer.Process(); } }
public void Set(ZRender.IRenderObject obj) { this.obj = obj; }
public static T CreateEmptyInstance <T>(ZRender.IRenderObject parent, params object[] args) where T : ZRender.IRenderObject { return(factory.CreateEmptyInstance <T>(parent, args)); }
public static T CreateInstance <T>(string filename, ZRender.IRenderObject parent, params object[] args) where T : ZRender.IRenderObject { return(factory.CreateInstance <T>(filename, parent, false, args)); }
internal void Create(IRenderObject owner) { this.RenderObject = owner; this.enabled = true; OnCreate(); }