AttachCardPoolPrefab.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using UnityEngine.Events;
  6. using System;
  7. using System.Reflection;
  8. using UnityEngine.UI;
  9. using UnityEngine.EventSystems;
  10. using Photon;
  11. using Photon.Pun;
  12. using System.Linq;
  13. public class AttachCardPoolPrefab : MonoBehaviour
  14. {
  15. [MenuItem("Window/Attach/AttachCardPoolPrefab")]
  16. static void Attach_CardPoolPrefab()
  17. {
  18. EditDeck editDeck = null;
  19. List<CardPrefab_CreateDeck> cardPrefab_CreateDecks_all = new List<CardPrefab_CreateDeck>();
  20. foreach (GameObject obj in Selection.gameObjects)
  21. {
  22. if(obj.GetComponent<EditDeck>() != null)
  23. {
  24. editDeck = obj.GetComponent<EditDeck>();
  25. }
  26. ScrollRect scrollRect = obj.GetComponent<ScrollRect>();
  27. if (scrollRect != null)
  28. {
  29. for(int i=0;i< scrollRect.content.childCount;i++)
  30. {
  31. CardPrefab_CreateDeck cardPrefab_CreateDeck = scrollRect.content.GetChild(i).GetComponent<CardPrefab_CreateDeck>();
  32. if (cardPrefab_CreateDeck != null)
  33. {
  34. cardPrefab_CreateDecks_all.Add(cardPrefab_CreateDeck);
  35. }
  36. }
  37. }
  38. }
  39. if(editDeck != null)
  40. {
  41. if(cardPrefab_CreateDecks_all.Count > 0)
  42. {
  43. editDeck.cardPoolPrefabs_all = cardPrefab_CreateDecks_all;
  44. }
  45. }
  46. }
  47. }