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

SwapFullSkin.cs 1.1KB

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