Esempio n. 1
0
        protected virtual void Update()
        {
            HashSet <Attachment> nullSet = new HashSet <Attachment>();

            foreach (Attachment attachment in attachments)
            {
                if (attachment == null)
                {
                    nullSet.Add(attachment);
                    continue;
                }
                AbstractPositionBinder a = attachment as AbstractPositionBinder;
                float angle = Vector3.Angle(Camera.transform.forward, a.transform.position - Camera.transform.position);
                RectTransformGroup group = map[attachment];
                if (a.IsActived() && angle <= Camera.fieldOfView && block == 0)
                {
                    a.OnShow(group.rectTransforms);
                    Vector3 position = Camera.WorldToScreenPoint(a.transform.position);

                    a.OnAdapte(group.rectTransforms, position);
                }
                else
                {
                    a.OnHide(group.rectTransforms);
                }
            }
            foreach (Attachment attachment in nullSet)
            {
                Remove(attachment);
            }
        }
Esempio n. 2
0
        public override bool Add(Attachment attachment)
        {
            if (!base.Add(attachment))
            {
                return(false);
            }
            AbstractPositionBinder a = attachment as AbstractPositionBinder;

            if (a is BlockedPositionBinder)
            {
                block++;
            }
            if (map == null)
            {
                map = new Dictionary <Attachment, RectTransformGroup>();
            }
            RectTransformGroup group = new RectTransformGroup(a.GenerateComponents(gameObject));

            foreach (RectTransform rectTransform in group.rectTransforms)
            {
                ContextProxy[] contexts = rectTransform.GetComponentsInChildren <ContextProxy>();
                foreach (ContextProxy context in contexts)
                {
                    context.RealContext = a.context;
                }
            }
            transformGroups.Add(group);
            map[attachment] = group;
            return(true);
        }