예제 #1
0
        public static GameObject CreateGlobalControl()
        {
            GlobalControl globalCtrl = GameObject.FindObjectOfType <GlobalControl>();

            if (globalCtrl)
            {
                return(globalCtrl.gameObject);
            }
            else
            {
                GameObject globalCtrlGO = new GameObject("Global_CTRL");
                Undo.RegisterCreatedObjectUndo(globalCtrlGO, "Created globalCTRL");

                globalCtrlGO.AddComponent <GlobalControl>();

                return(globalCtrlGO);
            }
        }
        public void Init()
        {
            if (ConstrainedControl != null)
            {
                _constrainedControlPosOffset = ConstrainedControl.position;
                _constrainedControlRotOffset = ConstrainedControl.rotation;

                _constrainedControlRotOffsetDif = Quaternion.Inverse(FK.rotation) * _constrainedControlRotOffset;
            }
            GlobalControl gc = transform.GetComponentInParent <GlobalControl>();

            if (gc != null)
            {
                _globalControlTrans = gc.transform;
            }

            L = 0f;
            Run();
            if (FK.parent)
            {
                L = Vector3.Distance(FK.position, FK.parent.position);
            }
            _initialRotation = transform.localRotation;
        }