2020년 6월 3일 수요일

Unity[유니티] List SearchLogic[검색기능]



/// <summary>
    /// 검색할 인자를 dict에 저장한다음에 원하는 것만 불러온다
    /// </summary>
    /// <param name="name">검색하려는 targetName</param>
    public void Search(string name)
    {
    
        //idx에 따른 검색 요소가 있는 것들을 List로 저장하기 위해 선언한 변수
        Dictionary<intList<int>> targetdic = new Dictionary<intList<int>>();

        //key 추가
        for (int i = 0i < m_slabList.Counti++)
        {
            targetdic.Add(i,new List<int>());
        }

        //있는지 체크해서 dict에 저장
        for (int i = 0i < m_slabList.Counti++)
        {
            List<intinsideIdx = new List<int>();
            for (int k = 0k < m_slabList[i].mySlabs.Countk++)
            {
                if (m_slabList[i].mySlabs[k].Contains(name))
                {
                    insideIdx.Add(k);
                }
                targetdic[i] = insideIdx;
            }
        }
        



        bool isable = false;

        foreach (var x in targetdic)
        {
            //하나라도 검색할수있으면 가능하다
            if (x.Value.Count != 0)
            {
                isable = true;
                break;
            }
        }

        //하나도 없다면 그냥 return
        if (!isable)
            return;

       
        //dict에 있는 리스트만 활성화하기!!
        for (int i = 0i < m_slabList.Counti++)
        {           
            if (targetdic[i].Count == 0)
            {
                m_slabList[i].populateGrid.tmp_SetActiveAllFalse();
            }
            else
            {
                m_slabList[i].populateGrid.tmp_SetActiveFalse(targetdic[i]);
            }
        }
        

    }




댓글 없음:

댓글 쓰기

git rejected error(feat. cherry-pick)

 문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...