Esempio n. 1
0
    static void attachAIBone(Transform bone, bool isRoot = false)
    {
        AIBone b = bone.GetComponent <AIBone>();

        if (b == null)
        {
            b = bone.gameObject.AddComponent <AIBone> ();
        }
        if (!isRoot)
        {
            b.length    = (b.transform.position - b.transform.parent.position).magnitude;
            b.minLength = b.maxLength = b.length;
        }
        for (int i = 0, max = bone.childCount; i < max; ++i)
        {
            attachAIBone(bone.GetChild(i));
        }
    }
Esempio n. 2
0
    static void DrawAllBone(AIBone bone, GizmoType gizmoType)    //AIBone改成Transform那么所有的Transform会被调用该函数
    {
        SceneView sv = SceneView.currentDrawingSceneView;

        if (sv == null)        //game window
        {
            return;
        }
        bool  sel = (gizmoType & GizmoType.Selected) != 0;
        Color oc  = Gizmos.color;

        Handles.color = sel?Color.green:Color.white;
        if (bone.isChild(Selection.activeTransform))
        {
            Handles.color = Color.magenta;
        }
        Transform transform = bone.transform;

        int cc = transform.childCount;

        for (int i = 0; i < cc; ++i)
        {
            Handles.DrawLine(transform.position, transform.GetChild(i).position);
        }

        if (sel)
        {
            Camera c = sv.camera;
            transform.rotation.SetLookRotation(c.transform.position);
            Quaternion q = Quaternion.identity;
            q.SetLookRotation(c.transform.position - transform.position);
            Handles.CircleCap(0, transform.position, q, 0.2f);

            Quaternion handleRotation = Tools.pivotRotation == PivotRotation.Local ? transform.rotation : Quaternion.identity;
            transform.position = Handles.DoPositionHandle(transform.position, handleRotation);
            Handles.Label(transform.position, transform.gameObject.name);
        }
        Handles.color = oc;
    }
Esempio n. 3
0
 void OnEnable()
 {
     mAIBone = target as AIBone;
     mOldQ   = mAIBone.transform.localRotation;
     mOldP   = mAIBone.transform.localPosition;
 }