Example #1
0
        /// <summary>
        /// Updates the supplied depth list using the order list<br/>
        /// Generally, it removes all the depth values, refills the list, and then sorts by the child Depth value
        /// </summary>
        /// <param name="orderList"></param>
        /// <param name="depthList"></param>
        // ReSharper disable SuggestBaseTypeForParameter
        private static void UpdateDrawingList(List<DisplayListMember> orderList, List<DisplayListMember> depthList)
        // ReSharper restore SuggestBaseTypeForParameter
        {
            //Debug.Log(string.Format("                  ! -> [orderList: {0}, depthList: {1}]", orderList.Count, depthList.Count));

            /**
             * 1. Empty the list
             * */
            depthList.Clear();

            int len = orderList.Count;

            /**
             * 2. Fill the list with values from the order list
             * */
            foreach (DisplayListMember displayListMember in orderList)
            {
                depthList.Add(displayListMember);
            }

            //Debug.Log("     depthList.Count: " + depthList.Count);

            if (len <= 1)
            {
#if DEBUG
                if (DebugMode)
                {
                    Debug.Log(string.Format("                       -> [orderList: {0}, depthList: {1}] *", orderList.Count, depthList.Count));
                }
#endif
                return; // don't bother
            }

            /**
             * 3. Sort by Depth
             * */
            for (int i = 1; i < len; i++)
            {
                for (int j = i; j > 0; j--)
                {
                    if (depthList[j].Depth < depthList[j - 1].Depth)
                    {
                        _tmp = depthList[j];
                        depthList[j] = depthList[j - 1];
                        depthList[j - 1] = _tmp;
                    }
                    //else
                    //    break;
                }
            }

            //Debug.Log(ListUtil<DisplayListMember>.Format(depthList));

#if DEBUG
            if (DebugMode)
            {
                Debug.Log(string.Format("                       -> [orderList: {0}, depthList: {1}]", orderList.Count, depthList.Count));
            }
#endif
        }