1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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 quaternion = base.transform.rotation;
- base.OnRenderObject();
- if (this.target_trans != null && quaternion != base.transform.rotation)
- {
- if (this.rotate_limit_ != null)
- {
- bool flag;
- quaternion = this.rotate_limit_.GetLimitedLocalRotation(this.target_trans.localRotation, out flag);
- if (flag)
- {
- this.target_trans.localRotation = quaternion;
- base.transform.rotation = this.target_trans.rotation;
- }
- else
- {
- this.target_trans.rotation = base.transform.rotation;
- }
- }
- else
- {
- this.target_trans.rotation = base.transform.rotation;
- }
- }
- }
- public Transform target_trans;
- public IKManager ik_mgr;
- private Transform backup_trans_;
- private RotationLimit rotate_limit_;
- }
|