1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- namespace MetaClient
- {
- public class AniPickOnImage : MonoBehaviour
- {
- public AniManager bonePicture;
- public BonePicTarget bonePicTarget;
- void Start()
- {
- if (this.gameObject.GetComponent<Button>() == null)
- {
- Button _button = this.gameObject.AddComponent<Button>();
- _button.onClick.AddListener(PickOn);
- }
- }
- public void PickOn()
- {
- if (bonePicture.eIKPickOnButtonStyple == EIKPickOnButtonStyple.None || bonePicture.eIKPickOnButtonStyple == EIKPickOnButtonStyple.Choose)
- {
- Image _image = this.gameObject.GetComponent<Image>();
- int _index = bonePicture.chooseImage.IndexOf(bonePicTarget);
- if (_index == -1)
- {
- if (bonePicture.chooseImage.Count == 0)
- {
- Choose();
- }
- else
- {
- Transform _bonePar = bonePicture.chooseImage[bonePicture.chooseImage.Count - 1].bone;
- foreach (Transform child in _bonePar)
- {
- if (child == bonePicTarget.bone)
- {
- Choose();
- }
- }
- }
- }
- else
- {
- Cancel();
- }
- }
- }
- public void Choose()
- {
- Image _image = this.gameObject.GetComponent<Image>();
- bonePicture.chooseImage.Add(bonePicTarget);
- _image.color = Color.blue;
- }
- public void Cancel()
- {
- Image _image = this.gameObject.GetComponent<Image>();
- int _index = bonePicture.chooseImage.IndexOf(bonePicTarget);
- bonePicture.chooseImage.RemoveAt(_index);
- _image.color = Color.red;
- }
- }
- }
|