123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using System;
- using SRF;
- using UnityEngine;
- namespace SRDebugger.UI.Other
- {
- public class HandleManager : SRMonoBehaviour
- {
- private void Start()
- {
- if (!this._hasSet)
- {
- this.SetAlignment(this.DefaultAlignment);
- }
- }
- public void SetAlignment(PinAlignment alignment)
- {
- this._hasSet = true;
- switch (alignment)
- {
- case PinAlignment.TopLeft:
- case PinAlignment.TopRight:
- this.SetActive(this.BottomHandle, true);
- this.SetActive(this.TopHandle, false);
- this.SetActive(this.TopLeftHandle, false);
- this.SetActive(this.TopRightHandle, false);
- break;
- case PinAlignment.BottomLeft:
- case PinAlignment.BottomRight:
- this.SetActive(this.BottomHandle, false);
- this.SetActive(this.TopHandle, true);
- this.SetActive(this.BottomLeftHandle, false);
- this.SetActive(this.BottomRightHandle, false);
- break;
- }
- switch (alignment)
- {
- case PinAlignment.TopLeft:
- case PinAlignment.BottomLeft:
- this.SetActive(this.LeftHandle, false);
- this.SetActive(this.RightHandle, true);
- this.SetActive(this.TopLeftHandle, false);
- this.SetActive(this.BottomLeftHandle, false);
- break;
- case PinAlignment.TopRight:
- case PinAlignment.BottomRight:
- this.SetActive(this.LeftHandle, true);
- this.SetActive(this.RightHandle, false);
- this.SetActive(this.TopRightHandle, false);
- this.SetActive(this.BottomRightHandle, false);
- break;
- }
- switch (alignment)
- {
- case PinAlignment.TopLeft:
- this.SetActive(this.BottomLeftHandle, false);
- this.SetActive(this.BottomRightHandle, true);
- break;
- case PinAlignment.TopRight:
- this.SetActive(this.BottomLeftHandle, true);
- this.SetActive(this.BottomRightHandle, false);
- break;
- case PinAlignment.BottomLeft:
- this.SetActive(this.TopLeftHandle, false);
- this.SetActive(this.TopRightHandle, true);
- break;
- case PinAlignment.BottomRight:
- this.SetActive(this.TopLeftHandle, true);
- this.SetActive(this.TopRightHandle, false);
- break;
- }
- }
- private void SetActive(GameObject obj, bool active)
- {
- if (obj == null)
- {
- return;
- }
- obj.SetActive(active);
- }
- private bool _hasSet;
- public GameObject BottomHandle;
- public GameObject BottomLeftHandle;
- public GameObject BottomRightHandle;
- public PinAlignment DefaultAlignment;
- public GameObject LeftHandle;
- public GameObject RightHandle;
- public GameObject TopHandle;
- public GameObject TopLeftHandle;
- public GameObject TopRightHandle;
- }
- }
|