private void UpdateSprite(object arg) { if (this.Target != null && arg != null) { if (arg is SpriteRenderer) { SpriteRenderer spriteRenderer = arg as SpriteRenderer; ResourceManager.SetSprite(this.Target, (SpriteRenderer)arg); if (this.SetNativeSize) { this.Target.SetNativeSize(); } if (this.RefreshLayout) { LayoutElement component = base.get_transform().GetComponent <LayoutElement>(); if (component != null) { component.set_preferredWidth(-1f); } } if (this.SetLayoutIgnoreWhenEmpty) { LayoutElement component2 = base.get_transform().GetComponent <LayoutElement>(); if (component2 != null) { if (spriteRenderer != null && spriteRenderer.get_sprite() != null && spriteRenderer.get_sprite().get_name().Equals("Empty")) { component2.set_ignoreLayout(true); } else if ((Sprite)arg == null) { component2.set_ignoreLayout(true); } else { component2.set_ignoreLayout(false); } } } } else { Debuger.Error("===arg invalid, it need arg is sprite.", new object[0]); } } }
private void SetIgnoreLayout(object arg) { if (arg != null) { bool ignoreLayout = (bool)arg; LayoutElement component = base.GetComponent <LayoutElement>(); component.set_ignoreLayout(ignoreLayout); } }