暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SwapFullSkin.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.U2D.Animation;
  4. #if UGUI_ENABLED
  5. using UnityEngine.UI;
  6. #endif
  7. namespace Unity.U2D.Animation.Sample
  8. {
  9. internal class SwapFullSkin : MonoBehaviour
  10. {
  11. public SpriteLibraryAsset[] spriteLibraries;
  12. public SpriteLibrary spriteLibraryTarget;
  13. #if UGUI_ENABLED
  14. public Dropdown dropDownSelection;
  15. #endif
  16. // Start is called before the first frame update
  17. void Start()
  18. {
  19. UpdateSelectionChoice();
  20. }
  21. void OnDropDownValueChanged(int value)
  22. {
  23. spriteLibraryTarget.spriteLibraryAsset = spriteLibraries[value];
  24. }
  25. internal void UpdateSelectionChoice()
  26. {
  27. #if UGUI_ENABLED
  28. dropDownSelection.ClearOptions();
  29. var options = new List<Dropdown.OptionData>(spriteLibraries.Length);
  30. for (int i = 0; i < spriteLibraries.Length; ++i)
  31. {
  32. options.Add(new Dropdown.OptionData(spriteLibraries[i].name));
  33. }
  34. dropDownSelection.options = options;
  35. dropDownSelection.onValueChanged.AddListener(OnDropDownValueChanged);
  36. #endif
  37. }
  38. }
  39. }