12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- using RootMotion.FinalIK;
- using UnityEngine;
- public class GizmoRenderTarget : GizmoRender
- {
- public void OnEnable()
- {
- if (this.backup_trans_ == null)
- {
- return;
- }
- this.rotate_limit_ = null;
- if (this.target_trans != null)
- {
- this.rotate_limit_ = this.GetLimitComponet();
- }
- }
- private RotationLimit GetLimitComponet()
- {
- if (this.target_trans == null)
- {
- return null;
- }
- return this.target_trans.gameObject.GetComponent<RotationLimit>();
- }
- public new void Update()
- {
- if (this.backup_trans_ != this.target_trans)
- {
- this.backup_trans_ = this.target_trans;
- this.rotate_limit_ = null;
- if (this.target_trans != null)
- {
- this.rotate_limit_ = this.GetLimitComponet();
- }
- }
- if (this.target_trans != null)
- {
- base.transform.position = this.target_trans.position;
- base.transform.rotation = this.target_trans.rotation;
- }
- }
- public override void OnDragEnd()
- {
- if (this.ik_mgr != null)
- {
- this.ik_mgr.HistoryPush();
- }
- }
- public override void OnRenderObject()
- {
- Quaternion rotation = base.transform.rotation;
- base.OnRenderObject();
- if (this.target_trans != null && rotation != base.transform.rotation)
- {
- this.target_trans.rotation = base.transform.rotation;
- if (this.rotate_limit_ != null)
- {
- this.rotate_limit_.Apply();
- }
- }
- }
- public Transform target_trans;
- public IKManager ik_mgr;
- private Transform backup_trans_;
- private RotationLimit rotate_limit_;
- }
|