示例#1
0
    void preRender(ScrollRectItem item, int index)
    {
        setPosition(item.transform, index);
        if (this.onPreRender == null)
        {
            onPreRender = LuaState.main.loadString(PreRenderStr, "onPreRenderStr");
        }
        object dataI = index + 1 <= recordCount?data[index + 1]:null;

        onPreRender.call(item, index, dataI);
    }
示例#2
0
    public int GetIndex(ScrollRectItem item)
    {
        int i = this.repositionTileList.IndexOf(item);
        int j = -1;

        if (i >= 0)
        {
            j = this.currFirstIndex + i;
        }
        return(j);
    }
    void preRender(ScrollRectItem item, int index)
    {
        setPosition(item.transform, index);
        if (this.onPreRender == null)
        {
            onPreRender = PLua.instance.lua.lua.LoadString(PreRenderStr, "onPreRenderStr");
        }
        object dataI = index + 1 <= recordCount?data[index + 1]:null;

        onPreRender.Call(item, index, dataI);
    }
示例#4
0
    void PreRender(ScrollRectItem item, int index)
    {
        SetPosition(item.rectTransform, index);
        if (this.onPreRender == null)
        {
            onPreRender = (LuaFunction)LuaState.main.doString(PreRenderStr, "onPreRenderStr");
        }
        object dataI = index + 1 <= recordCount ? data[index + 1] : null;

        onPreRender.call(item, index + 1, dataI);
    }
    public void SetReferName(ScrollRectItem refer, int i)
    {
        while (refer.names.Count <= i)
        {
            refer.names.Add(null);
        }
        Rect rect = GUILayoutUtility.GetLastRect();

        rect.xMin      = 30;
        rect.width     = 70;
        refer.names[i] = EditorGUI.TextField(rect, refer.names[i]);
        GUILayout.Space(70);
    }
示例#6
0
    public int removeChild(ScrollRectItem item)
    {
        int i = getIndex(item);

        if (i >= 0)
        {
            if (onDataRemove == null)
            {
                onDataRemove = LuaState.main.loadString(DataRemoveStr, "onDataRemove");
            }
            onDataRemove.call(this.data, i + 1, this);
            this.CalcPage();
        }
        return(i);
    }
    public int removeChild(ScrollRectItem item)
    {
        int i = getIndex(item);

        if (i >= 0)
        {
            if (onDataRemove == null)
            {
                onDataRemove = PLua.instance.lua.lua.LoadString(DataRemoveStr, "onDataRemove");
            }
            onDataRemove.Call(this.data, i + 1, this);
            this.CalcPage();
        }
        return(i);
    }
示例#8
0
 void render()
 {
     if (this.preRenderList.Count > 0)
     {
         ScrollRectItem item = preRenderList[0];
         currRenderIndex = this.repositionIntList[0];
         preRenderList.RemoveAt(0);
         repositionIntList.RemoveAt(0);
         if (currRenderIndex + 1 <= recordCount)
         {
             if (onItemRender != null)
             {
                 onItemRender.call(item, currRenderIndex, data[currRenderIndex + 1]);
             }
         }
     }
 }
示例#9
0
    void preRightDown(int i)
    {
        if (i >= 0 && !repositionIntList.Contains(i) && i + pageSize <= recordCount)  //i>pageSize)//
        {
            int            end1 = repositionTileList.Count - 1;
            ScrollRectItem tile = repositionTileList[end1];
            repositionTileList.RemoveAt(end1);   //remove end
            repositionTileList.Insert(0, tile);  //to first

            this.preRenderList.Add(tile);        //add to preRenderList
            repositionIntList.Add(i);            //add data index
            currFirstIndex--;
            if (currFirstIndex < 0)
            {
                currFirstIndex = 0;
            }
            CalcLastEndIndex();
            scrollDirection = -1;
            preRender(tile, i);
        }
    }
    public void AddMonos(ScrollRectItem refer, int i, UnityEngine.Object obj)
    {
        List<UnityEngine.Object> monos = null;

        if (refer.monos != null)
            monos = new List<UnityEngine.Object>(refer.monos);
        else
            monos = new List<UnityEngine.Object>();

        //monos.Add(obj);
        if (i < 0)
        {
            monos.Add(obj);
        }
        else
        {
            while (monos.Count <= i)
                monos.Add(null);
            monos[i] = obj;
        }
        refer.monos = monos.ToArray();
    }
示例#11
0
    void preLeftUp(int i)
    {
        if (i >= this.pageSize && !repositionIntList.Contains(i) && i < this.recordCount)
        {
            ScrollRectItem tile = repositionTileList[0];
            repositionTileList.RemoveAt(0);      //remove first
            repositionTileList.Add(tile);        //to end

            this.preRenderList.Add(tile);        //add to preRenderList
            repositionIntList.Add(i);            //add data index

            currFirstIndex++;
            if (currFirstIndex + pageSize > recordCount)
            {
                currFirstIndex = recordCount - this.pageSize;
            }

            this.lastEndIndex = i;        //recorde last render data index
            scrollDirection   = 1;
            preRender(tile, i);           //call preRender,set Postion
        }
    }
示例#12
0
 /// <summary>
 /// Refresh the specified item's position.
 /// </summary>
 /// <param name='item'>
 /// Item.
 /// </param>
 public void Refresh(ScrollRectItem item)
 {
     int i=getIndex(item);
     if(i>=0)
     {
         i=i+currFirstIndex;
         preRefresh(i);
     }
 }
示例#13
0
 public int getIndex(ScrollRectItem item)
 {
     int i=this.repositionTileList.IndexOf(item);
     int j=-1;
     if(i>=0)j=this.currFirstIndex+i;
     return j;
 }
示例#14
0
	public int RemoveChild(ScrollRectItem item)
	{
		int i=GetIndex(item);
		if(i>=0)
		{
            if (onDataRemove == null) onDataRemove = (LuaFunction)LuaState.main.doString(DataRemoveStr, "onDataRemove");
            onDataRemove.call(this.data,i+1,this);
			this.CalcPage();
        }
		return i;
	}
示例#15
0
	void PreRender(ScrollRectItem item,int index)
	{
		SetPosition(item.transform,index);
        if (this.onPreRender == null) onPreRender = (LuaFunction)LuaState.main.doString(PreRenderStr, "onPreRenderStr");
		object dataI=index+1<=recordCount?data[index+1]:null;
		onPreRender.call(item,index,dataI);
	}
示例#16
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Mono List", GUILayout.Width(200));
        ScrollRectItem temp = target as ScrollRectItem;

        Undo.RecordObject(target, "F");
        if (temp.monos != null)
        {
            for (int i = 0; i < temp.monos.Length; i++)
            {
                List <Type> allowTypes = new List <Type>()
                {
                    typeof(GameObject)
                };
                int selectIndex = 0;

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label((i + 1).ToString(), GUILayout.Width(20));
                SetReferName(temp, i);
                UnityEngine.Object obj = GetMonos(temp, i);
                if (obj != null)
                {
                    Type       currentType = obj.GetType();
                    GameObject go          = null;
                    if (currentType == typeof(GameObject))
                    {
                        go = (GameObject)obj;
                    }
                    else if (currentType.IsSubclassOf(typeof(Component)))
                    {
                        go = ((Component)obj).gameObject;
                    }
                    Component[] cs = null;

                    if (go != null)
                    {
                        cs = go.GetComponents <Component>();

                        for (int j = 0; j < cs.Length; j++)
                        {
                            allowTypes.Add(cs[j].GetType());
                            if (obj == cs[j])
                            {
                                selectIndex = j + 1;
                            }
                        }
                        selectIndex = EditorGUILayout.Popup(selectIndex, ConvertTypeArrayToStringArray(allowTypes));
                        if (selectIndex == 0)
                        {
                            AddMonos(temp, i, go); //temp.monos[i] = go;
                        }
                        else
                        {
                            AddMonos(temp, i, cs[selectIndex - 1]);  //temp.monos[i] = cs[selectIndex - 1];
                        }
                    }
                    if (temp.names[i] == "")
                    {
                        temp.names[i] = obj.name;
                    }
                }

                AddMonos(temp, i, EditorGUILayout.ObjectField(GetMonos(temp, i), typeof(UnityEngine.Object), true));

                var objfind = GetMonos(temp, i);
                if (temp.names.Count > i && temp.names[i] != "" && objfind != null && temp.names[i] != objfind.name)
                {
                    if (GUILayout.Button("Auto", GUILayout.Width(50)))
                    {
                        temp.names[i] = "";
                    }
                }
                if (GUILayout.Button("Del", GUILayout.Width(40)))
                {
                    temp.names.RemoveAt(i);
                    RemoveAtMonos(temp, i);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.Space();

        if (GUILayout.Button("Add Item"))
        {
            temp.names.Add("");
            AddMonos(temp, -1, null);
        }
        EditorGUILayout.Space();
        EditorGUILayout.EndHorizontal();
        EditorUtility.SetDirty(target);
    }
示例#17
0
 public void SetReferName(ScrollRectItem refer, int i)
 {
     while (refer.names.Count <= i)
         refer.names.Add(null);
     refer.names[i] = GUILayout.TextField(refer.names[i], GUILayout.Width(60));
 }
示例#18
0
 public UnityEngine.Object GetMonos(ScrollRectItem refer, int index)
 {
     if (index >= 0 && index < refer.monos.Length)
         return refer.monos[index];
     return null;
 }
示例#19
0
 public int removeChild(ScrollRectItem item)
 {
     int i=getIndex(item);
     if(i>=0)
     {
         if (onDataRemove == null) onDataRemove = PLua.instance.lua.luaState.loadString(DataRemoveStr, "onDataRemove");
         onDataRemove.call(this.data,i+1,this);
         this.CalcPage();
     }
     return i;
 }
示例#20
0
 void preRender(ScrollRectItem item,int index)
 {
     setPosition(item.transform,index);
     if (this.onPreRender == null) onPreRender = PLua.instance.lua.luaState.loadString(PreRenderStr, "onPreRenderStr");
     object dataI=index+1<=recordCount?data[index+1]:null;
     onPreRender.call(item,index,dataI);
 }
示例#21
0
 public void RemoveAtMonos(ScrollRectItem refer, int index)
 {
     List<UnityEngine.Object> monos = new List<UnityEngine.Object>(refer.monos);
     monos.RemoveAt(index);
     refer.monos = monos.ToArray();
 }