Author Topic: Why this scrollview's inside child contents does not shown until click?  (Read 6951 times)

leegod

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 90
    • View Profile
https://youtu.be/u5afNmQtwkI

So like above video, below's cards does not shown. Until I click with mouse left inside that scrollview area.

How can I make it shown at first without the need of mouse click?

Here is code.
  1. public void MakeBattleHand()
  2.     {       //Make user's hand's card when battle mode
  3.         foreach (CardBase cd in HandCardClass)
  4.         {
  5.             AddCardToBattleHand(cd);
  6.         }
  7.     }
  8.     public void AddCardToBattleHand(CardBase cd)
  9.     {
  10.         GameObject go = Instantiate(cardPref);
  11.         AdvenUI.Instance.MoveObjToNGUITransform(go, handGridBat);
  12.         go.GetComponent<CardPreScript>().thisCard = cd;
  13.         go.name = cd.name;
  14.         MakeCardInfo(go, cd);
  15.         handScrollBat.transform.localPosition = new Vector3(0, 0, 0);
  16.         handScrollBat.UpdateScrollbars(true);
  17.     }
  18. ............
  19. public void MoveObjToNGUITransform(GameObject go,  UIGrid grid)    
  20.     {
  21.         if (go == null)
  22.             return;
  23.         go.transform.parent = grid.transform;
  24.         go.transform.position = CardManager.Instance.Tf_UI_Root.transform.position;
  25.         go.transform.localScale = new Vector3(1f, 1f, 1f);
  26.         go.transform.localRotation = Quaternion.identity;
  27.         grid.Reposition();
  28.         grid.repositionNow = true;
  29.         grid.transform.parent.GetComponent<UIScrollView>().ResetPosition();
  30.         NGUITools.MarkParentAsChanged(go);
  31.         grid.transform.parent.localPosition = new Vector3(0, 0, 0);
  32.         SetCard.Instance.ShowDeckNum();
  33.     }
  34.  
  35.  



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
You are changing the transform's parent, but never notify the NGUI that this happened.

Use NGUITools.MarkParentAsChanged(gameObject)

leegod

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 90
    • View Profile
You are changing the transform's parent, but never notify the NGUI that this happened.

Use NGUITools.MarkParentAsChanged(gameObject)

I called  NGUITools.MarkParentAsChanged(go);  already in my second function.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Ah, sorry guess I missed that. Should work then. If nothing else, just try calling NGUITools.ImmediatelyCreateDrawCalls on your panel at the very end.