예제 #1
0
    protected virtual void OnItemInsert(int position, EZData.Context item)
    {
        GameObject itemObject = null;

        if (_itemTemplate != null && _cache.Count < MaxItemCount)
        {
            itemObject = _itemTemplate.Instantiate(item, position, _groupNumber);

            _cache.Insert(position, itemObject);

            itemObject.transform.SetParent(transform);
            itemObject.transform.localScale    = Vector3.one;
            itemObject.transform.localPosition = Vector3.back;

            //TODO: IMPORTANT
//            retinaProUtil.sharedInstance.refreshVisible(itemObject);
        }
        else
        {
            if (position < transform.childCount)
            {
                itemObject = transform.GetChild(position).gameObject;
                var itemData = itemObject.GetComponent <NguiItemDataContext>();
                if (itemData != null)
                {
                    itemData.SetContext(item);
                    itemData.SetIndex(position);
                }
            }
        }
        if (itemObject != null)
        {
            foreach (var dragObject in itemObject.GetComponentsInChildren <UIDragObject>())
            {
                if (dragObject.target == null)
                {
                    dragObject.target = transform;
                }
            }
            foreach (var dragObject in itemObject.GetComponents <UIDragObject>())
            {
                if (dragObject.target == null)
                {
                    dragObject.target = transform;
                }
            }

            var parentVisibility = NguiUtils.GetComponentInParentsAs <IVisibilityBinding>(gameObject);
            foreach (var visibility in NguiUtils.GetComponentsInChildrenAs <IVisibilityBinding>(itemObject))
            {
                visibility.InvalidateParent();
            }
            var visible = parentVisibility == null ? true : parentVisibility.Visible;
            NguiUtils.SetVisible(itemObject, visible);

            RepositionContent();
        }
    }
    public void SetContext(EZData.Context c)
    {
        _context = c;

        var bindings = gameObject.GetComponentsInChildren <NguiBaseBinding>();

        foreach (var binding in bindings)
        {
            binding.UpdateBinding();
        }
    }
	private EZData.Property<string> GetDisplayValueProperty(EZData.Context item)
	{
		if (item == null)
			return null;
		
		EZData.Property<string> property = null;
		if (_displayValuesCache.TryGetValue(item, out property))
			return property;
		property = item.FindProperty<string>(DisplayValuePath, this);
		if (property != null)
			_displayValuesCache.Add(item, property);
		return property;
	}
예제 #4
0
    public GameObject Instantiate(EZData.Context itemContext, int index, int groupNumber)
    {
        if (Template == null)
        {
            return(null);
        }

        GameObject instance;

        instance = (GameObject)Instantiate(Template);



        var subTemplates = instance.GetComponentsInChildren <NguiListItemTemplate>();

        foreach (var st in subTemplates)
        {
            if (st.Template == instance)
            {
                st.Template = Template;
            }
        }

        foreach (UIDragCamera cd in instance.GetComponentsInChildren <UIDragCamera>())
        {
            if (cd.draggableCamera == null && DraggableCamera != null)
            {
                cd.draggableCamera = DraggableCamera;
            }
        }
        var itemData = instance.AddComponent <NguiItemDataContext>();

        instance.transform.SetParent(transform);
        itemData.SetContext(itemContext);
        instance.transform.SetParent(null);

        itemData.SetIndex(index);

        var toggle = itemData.GetComponent <UIToggle> ();

        if (toggle != null)
        {
            toggle.group = groupNumber;
        }

//		if(retinaProUtil.sharedInstance != null)
//			retinaProUtil.sharedInstance.refreshVisible (instance);

        return(instance);
    }
예제 #5
0
    public virtual GameObject Instantiate(EZData.Context itemContext, int index)
    {
        if (Template == null)
        {
            return(null);
        }

        GameObject instance = (GameObject)Instantiate(Template);

        var subTemplates = instance.GetComponentsInChildren <NguiListItemTemplate>();

        foreach (var st in subTemplates)
        {
            if (st.Template == instance)
            {
                st.Template = Template;
            }
        }

        foreach (UIDragCamera cd in instance.GetComponentsInChildren <UIDragCamera>())
        {
            if (cd.draggableCamera == null && DraggableCamera != null)
            {
                cd.draggableCamera = DraggableCamera;
            }
        }
        var itemData = instance.AddComponent <NguiItemDataContext>();

        instance.transform.parent = transform;
        itemData.SetContext(itemContext);
        instance.transform.parent = null;

        itemData.SetIndex(index);

        return(instance);
    }
예제 #6
0
    public void SetContext(EZData.Context c)
    {
        _context = c;
        if (gameObject.name == "FixedPlayerItem")
        {
            print("___");
        }

        var bindings = gameObject.GetComponentsInChildren <NguiBinding>();

        foreach (var binding in bindings)
        {
            binding.UpdateBinding();
        }

        var multiBindings = gameObject.GetComponentsInChildren <NguiMultiBinding>();

        foreach (var binding in multiBindings)
        {
            binding.UpdateBinding();
        }

        c.BindedGameObject = gameObject;
    }
	protected override void OnItemInsert(int position, EZData.Context item)
	{
		base.OnItemInsert(position, item);
		_uiPopupList.items.Insert(position, GetDisplayValueProperty(item).GetValue());
		AssignValue(GetItemDisplayValue(_collection.SelectedIndex));
	}
    protected virtual void OnItemInsert(int position, EZData.Context item)
    {
        GameObject itemObject = null;

        if (_itemTemplate != null)
        {
            itemObject = _itemTemplate.Instantiate(item, position);

            itemObject.name = string.Format("{0}", position);
            for (var i = 0; i < transform.childCount; ++i)
            {
                var child = transform.GetChild(i).gameObject;
                int childNumber;
                if (int.TryParse(child.name, out childNumber) && childNumber >= position)
                {
                    child.name = string.Format("{0}", childNumber + 1);
                }
            }
            itemObject.transform.parent        = gameObject.transform;
            itemObject.transform.localScale    = Vector3.one;
            itemObject.transform.localPosition = Vector3.back;
        }
        else
        {
            if (position < transform.childCount)
            {
                itemObject = transform.GetChild(position).gameObject;
                var itemData = itemObject.GetComponent <NguiItemDataContext>();
                if (itemData != null)
                {
                    itemData.SetContext(item);
                    itemData.SetIndex(position);
                }
            }
        }
        if (itemObject != null)
        {
            foreach (var dragObject in itemObject.GetComponentsInChildren <UIDragObject>())
            {
                if (dragObject.target == null)
                {
                    dragObject.target = gameObject.transform;
                }
            }
            foreach (var dragObject in itemObject.GetComponents <UIDragObject>())
            {
                if (dragObject.target == null)
                {
                    dragObject.target = gameObject.transform;
                }
            }

            var parentVisibility = NguiUtils.GetComponentInParentsAs <IVisibilityBinding>(gameObject);
            foreach (var visibility in NguiUtils.GetComponentsInChildrenAs <IVisibilityBinding>(itemObject))
            {
                visibility.InvalidateParent();
            }
            var visible = parentVisibility == null ? true : parentVisibility.Visible;
            NguiUtils.SetVisible(itemObject, visible);

            RepositionContent();
        }
    }
예제 #9
0
 public void SetContext(EZData.Context context)
 {
     _context = context;
 }