Esempio n. 1
0
        public void DestroyObject(object obj)
        {
            BridgeObject bridgeObject = obj as BridgeObject;

            //Debug.Log("Bridge: DestroyObject: ======== obj: " + obj + " bridgeObject: " + bridgeObject + " destroying: " + bridgeObject.destroying + " destroyed: " + bridgeObject.destroyed);

            string id = null;

            if ((bridgeObject != null) &&
                (bridgeObject.gameObject != null))
            {
                id = bridgeObject.id;

                //Debug.Log("Bridge: DestroyObject: bridgeObject: " + bridgeObject + " id: " + id + " checking destroyed: " + bridgeObject.destroyed + " destroying: " + bridgeObject.destroying);

                if (bridgeObject.destroyed)
                {
                    Debug.Log("Bridge: DestroyObject: already destroyed!");
                    return;
                }

                bridgeObject.destroyed = true;

                //Debug.Log("Bridge: DestroyObject: bridgeObject: " + bridgeObject + " id: " + id + " restarting: " + restarting);

                if (!restarting)
                {
                    bridgeObject.SendEventName("Destroyed");
                }

                //Debug.Log("Bridge: DestroyObject: DestroyImmediate: id: " + bridgeObject.id + " gameObject: " + bridgeObject.gameObject + " destroying: " + bridgeObject.destroying);
                if (!bridgeObject.destroying)
                {
                    DestroyImmediate(bridgeObject.gameObject);
                }
            }

            if (objectToID.ContainsKey(obj))
            {
                id = objectToID[obj];
                objectToID.Remove(obj);
            }
            else
            {
                //Debug.Log("Bridge: DestroyObject: objectToID missing obj: " + obj, this);
            }

            if ((id != null) &&
                (id != "bridge") &&
                idToObject.ContainsKey(id))
            {
                idToObject.Remove(id);
            }
            else
            {
                //Debug.Log("Bridge: DestroyObject: idToObject missing id: " + id, this);
            }
        }
Esempio n. 2
0
        public void DestroyObject(object obj)
        {
            BridgeObject bridgeObject = obj as BridgeObject;

            string id = null;

            if (bridgeObject != null)
            {
                if (bridgeObject.destroyed)
                {
                    return;
                }

                id = bridgeObject.id;
                bridgeObject.destroyed = true;

                //Debug.Log("Bridge: DestroyObject: bridgeObject: " + bridgeObject);

                if (!restarting)
                {
                    bridgeObject.SendEventName("Destroyed");
                }

                Destroy(bridgeObject.gameObject);
            }

            if (objectToID.ContainsKey(obj))
            {
                id = objectToID[obj];
                objectToID.Remove(obj);
            }
            else
            {
                //Debug.Log("Bridge: DestroyObject: objectToID missing obj: " + obj, this);
            }

            if ((id != null) &&
                (id != "bridge") &&
                idToObject.ContainsKey(id))
            {
                idToObject.Remove(bridgeObject.id);
            }
            else
            {
                //Debug.Log("Bridge: DestroyObject: idToObject missing id: " + id, this);
            }
        }
Esempio n. 3
0
        public bool ConvertFromType(object value, ref JToken result)
        {
            //Debug.Log("Bridge: ConvertFromType: value: " + value + " type: " + ((value == null) ? "NULL" : ("" + value.GetType())));

            if (value == null)
            {
                result = null;
                return(true);
            }

            // Convert bridge objects into object references.
            BridgeObject bo = value as BridgeObject;

            if (bo)
            {
                value = "object:" + bo.id;
            }

            result = JToken.FromObject(value, jsonSerializer);

            //Debug.Log("Bridge: ConvertFromType: result: " + result + " TokenType: " + result.Type);

            return(true);
        }
Esempio n. 4
0
        public virtual void TrackMousePosition()
        {
            mouseRaycastHitBridgeObject           = null;
            mouseRaycastHitBridgeObjectID         = null;
            mouseRaycastHitColliderBridgeObject   = null;
            mouseRaycastHitColliderBridgeObjectID = null;

            TrackKeyModifiers();

            isPointerOverUIObject = IsPointerOverUIObject();

            if (!mouseTrackingPosition)
            {
                return;
            }

            mousePosition        = Input.mousePosition;
            mousePositionChanged = mousePosition != mousePositionLast;

            screenSize =
                new Vector2(
                    Screen.width,
                    Screen.height);
            screenPosition =
                new Vector2(
                    mousePosition.x - (screenSize.x * 0.5f),
                    mousePosition.y - (screenSize.y * 0.5f));

            if (mouseTrackingPositionHover)
            {
                if (mouseTrackingPositionHovering)
                {
                    if (mousePositionChanged)
                    {
                        mouseTrackingPositionHovering  = false;
                        mouseTrackingPositionDriftTime = Time.time;
                        SendEventName("Drift");
                    }
                }
                else
                {
                    if (mousePositionChanged)
                    {
                        mouseTrackingPositionDriftTime = Time.time;
                    }
                    if ((Time.time - mouseTrackingPositionDriftTime) >= mouseTrackingPositionDriftDelay)
                    {
                        mouseTrackingPositionHovering = true;
                        SendEventName("Hover");
                    }
                }
            }

            mousePositionLast = mousePosition;

            if (Camera.main == null)
            {
                return;
            }

            mouseRay =
                Camera.main.ScreenPointToRay(
                    mousePosition);

            if (!mouseTrackingRaycast)
            {
                mouseRaycastResult = false;
            }
            else
            {
                mouseRaycastResult =
                    Physics.Raycast(
                        mouseRay,
                        out mouseRaycastHit,
                        mouseRayMaxDistance,
                        mouseRayLayerMask,
                        mouseRayQueryTriggerInteraction);

                //Debug.Log("Tracker: TrackMousePosition: mouseRaycastResult: " + mouseRaycastResult + " mouseRaycastHitPoint: " + mouseRaycastHit.point.x + " " + mouseRaycastHit.point.y + " " + mouseRaycastHit.point.z);

                if (!mouseRaycastResult)
                {
                }
                else
                {
                    Vector3 cameraPosition = Camera.main.transform.position;
                    Vector3 offset         = cameraPosition - mouseRaycastHit.point;
                    offset.y = 0.0f;
                    float direction =
                        (offset == Vector3.zero)
                        ? 0.0f
                        : (180.0f + (Mathf.Atan2(offset.x, offset.z) * Mathf.Rad2Deg));
                    mouseRaycastHitPointFaceCameraRotation =
                        Quaternion.Euler(0.0f, direction, 0.0f);

                    mouseRaycastHitBridgeObject = null;
                    Transform xform = mouseRaycastHit.transform;
                    while (xform != null)
                    {
                        mouseRaycastHitBridgeObject = xform.gameObject.GetComponent <BridgeObject>();
                        if (mouseRaycastHitBridgeObject != null)
                        {
                            break;
                        }

                        xform = xform.parent;
                    }

                    mouseRaycastHitBridgeObjectID =
                        (mouseRaycastHitBridgeObject == null)
                        ? null
                        : mouseRaycastHitBridgeObject.id;

                    mouseRaycastHitColliderBridgeObject = null;
                    xform = mouseRaycastHit.collider.transform;
                    while (xform != null)
                    {
                        mouseRaycastHitColliderBridgeObject = xform.gameObject.GetComponent <BridgeObject>();
                        if (mouseRaycastHitColliderBridgeObject != null)
                        {
                            break;
                        }

                        xform = xform.parent;
                    }

                    mouseRaycastHitColliderBridgeObjectID =
                        (mouseRaycastHitColliderBridgeObject == null)
                        ? null
                        : mouseRaycastHitColliderBridgeObject.id;
                }

                //Debug.Log("Tracker: TrackMousePosition: cameraPosition: " + cameraPosition.x + " " + cameraPosition.y + " " + cameraPosition.z + " point: " + mouseRaycastHit.point.x + " " + mouseRaycastHit.point.y + " " + mouseRaycastHit.point.z + " offset: " + offset.x + " " + offset.y + " " + offset.z + " direction: " + direction);
            }

            if (dragging)
            {
                float horizontalScale = -2.0f;
                float verticalScale   = 0.5f;

                dragScreenDistance =
                    mousePosition - dragLastMousePosition;
                dragLastMousePosition = mousePosition;

                float enter = 0.0f;
                if (dragPlane.Raycast(mouseRay, out enter))
                {
                    dragPlanePosition     = mouseRay.GetPoint(enter);
                    dragPlaneDistance     = dragPlanePosition - dragLastPlanePosition;
                    dragLastPlanePosition = dragPlanePosition;

                    if (Input.GetKey("left shift") ||
                        Input.GetKey("right shift"))
                    {
                        rotateAmount      = dragScreenDistance.x * horizontalScale;
                        dragPlaneDistance = new Vector3(0.0f, dragScreenDistance.y * verticalScale, 0.0f);
                    }
                    else
                    {
                        rotateAmount = 0.0f;
                    }
                }
                else
                {
                    dragPlaneDistance = Vector3.zero;
                    rotateAmount      = 0.0f;
                }

                if ((dragPlaneDistance != Vector3.zero) ||
                    (rotateAmount != 0.0f))
                {
                    Vector3 newPosition =
                        gameObject.transform.position + dragPlaneDistance;

                    Quaternion newRotation =
                        Quaternion.Euler(0.0f, rotateAmount, 0.0f) *
                        gameObject.transform.rotation;

                    Rigidbody rb =
                        gameObject.GetComponent <Rigidbody>();
                    if (rb != null)
                    {
                        rb.MovePosition(newPosition);

                        if (rotateAmount != 0.0f)
                        {
                            rb.MoveRotation(newRotation);
                        }
                    }
                    else
                    {
                        transform.position = newPosition;

                        if (rotateAmount != 0.0f)
                        {
                            transform.rotation = newRotation;
                        }
                    }

                    SendEventName("DragMove");
                }
            }

            HandleMouseMove();
        }
Esempio n. 5
0
        void DistributeUnityEvent(JObject ev)
        {
            string eventName = (string)ev["event"];

            //Debug.Log("Bridge: DistributeUnityEvent: eventName: " + eventName + " ev: " + ev);

            JObject data = ev["data"] as JObject;

            switch (eventName)
            {
            case "StartedJS": {
                //Debug.Log("Bridge: DistributeUnityEvent: StartedJS: " + ev);
                startedJS = true;

                break;
            }

            case "Log": {
                string line = (string)data["line"];

                Debug.Log("Bridge: DistributeUnityEvent: Log: line: " + line);

                break;
            }

            case "Create": {
                string  id                 = data.GetString("id");
                string  prefab             = data.GetString("prefab");
                string  component          = data.GetString("component");
                JArray  preEvents          = data.GetArray("preEvents");
                string  parent             = data.GetString("parent");
                bool    worldPositionStays = data.GetBoolean("worldPositionStays", true);
                JObject update             = data.GetObject("update");
                JObject interests          = data.GetObject("interests");
                JArray  postEvents         = data.GetArray("postEvents");

                //Debug.Log("Bridge: DistributeUnityEvent: Create: id: " + id + " prefab: " + prefab + " component: " + component + " preEvents: " + preEvents + " parent: " + parent + " worldPositionStay: " + worldPositionStays + " update: " + update + " interests: " + interests + " postEvents: " + postEvents);

                GameObject instance = null;
                if (string.IsNullOrEmpty(prefab))
                {
                    instance = new GameObject();
                }
                else
                {
                    GameObject prefabObject = Resources.Load <GameObject>(prefab);
                    //Debug.Log("Bridge: DistributeUnityEvent: Create: prefab: " + prefab + " prefabObject: " + prefabObject);
                    if (prefabObject == null)
                    {
                        Debug.LogError("Bridge: DistributeUnityEvent: Create: Can't find prefab: " + prefab);
                        return;
                    }
                    instance = Instantiate(prefabObject);
                    //Debug.Log("Bridge: DistributeUnityEvent: Create: instance: " + instance);
                    if (instance == null)
                    {
                        Debug.LogError("Bridge: DistributeUnityEvent: Create: Can't instantiate prefab: " + prefab + " prefabObject: " + prefabObject);
                        return;
                    }
                }

                BridgeObject bridgeObject;

                if (string.IsNullOrEmpty(component))
                {
                    bridgeObject = instance.GetComponent <BridgeObject>();
                    //Debug.Log("Bridge: DistributeUnityEvent: Create: bridgeObject: " + bridgeObject);

                    if (bridgeObject == null)
                    {
                        bridgeObject = instance.AddComponent <BridgeObject>();
                    }
                }
                else
                {
                    Type componentType = Type.GetType(component);

                    if (componentType == null)
                    {
                        componentType = Type.GetType("UnityJS." + component);
                    }

                    if (componentType == null)
                    {
                        componentType = Type.GetType("UnityEngine." + component);
                    }

                    if (componentType == null)
                    {
                        Debug.LogError("Bridge: DistributeUnityEvent: Create: undefined component class: " + component);
                        return;
                    }

                    if ((componentType != typeof(BridgeObject)) &&
                        (!componentType.IsSubclassOf(typeof(BridgeObject))))
                    {
                        Debug.LogError("Bridge: DistributeUnityEvent: Create: component class is not subclass of BridgeObject: " + component);
                        return;
                    }

                    bridgeObject = (BridgeObject)instance.AddComponent(componentType);
                }

                instance.name       = id;
                bridgeObject.id     = id;
                bridgeObject.bridge = this;
                bridgeObject.AddInterests(interests);
                objectToID[bridgeObject] = id;
                idToObject[id]           = bridgeObject;

                //Debug.Log("Bridge: DistributeUnityEvent: Create: created, position: " + bridgeObject.transform.position.x + " " + bridgeObject.transform.position.y + " " + bridgeObject.transform.position.z + " bridgeObject: " + bridgeObject, bridgeObject);

                if (preEvents != null)
                {
                    bridgeObject.HandleEvents(preEvents);
                }

                if (!String.IsNullOrEmpty(parent))
                {
                    //Debug.Log("BridgeObject: DistributeUnityEvent: Create: parent: bridgeObject: " + bridgeObject + " parent: " + parent);

                    Accessor accessor = null;
                    if (!Accessor.FindAccessor(
                            bridgeObject,
                            parent,
                            ref accessor))
                    {
                        Debug.LogError("Bridge: DistributeUnityEvent: Create: parent: can't find accessor for bridgeObject: " + bridgeObject + " parent: " + parent);
                    }
                    else
                    {
                        object obj = null;
                        if (!accessor.Get(ref obj))
                        {
                            if (!accessor.conditional)
                            {
                                Debug.LogError("Bridge: DistributeUnityEvent: Create: parent: can't get accessor: " + accessor + " bridgeObject: " + bridgeObject + " parent: " + parent);
                            }
                        }
                        else
                        {
                            Component comp = obj as Component;
                            if (comp == null)
                            {
                                if (!accessor.conditional)
                                {
                                    Debug.LogError("Bridge: DistributeUnityEvent: Create: parent: expected Component obj: " + obj + " this: " + this + " parent: " + parent);
                                }
                            }
                            else
                            {
                                GameObject go    = comp.gameObject;
                                Transform  xform = go.transform;
                                //Debug.Log("Bridge: DistributeUnityEvent: Create: parent: xform: " + xform + " parent: " + parent + " worldPositionStays: " + worldPositionStays);

                                bridgeObject.transform.SetParent(xform, worldPositionStays);
                            }
                        }
                    }
                }

                if (update != null)
                {
                    bridgeObject.LoadUpdate(update);
                }

                bridgeObject.SendEventName("Created");

                if (postEvents != null)
                {
                    bridgeObject.HandleEvents(postEvents);
                }

                //Debug.Log("Bridge: DistributeUnityEvent: Create: done, position: " + bridgeObject.transform.position.x + " " + bridgeObject.transform.position.y + " " + bridgeObject.transform.position.z + " bridgeObject: " + bridgeObject);

                break;
            }

            default: {
                string id = (string)ev["id"];
                //Debug.Log("Bridge: DistributeUnityEvent: id: " + id + " ev: " + ev);

                if (string.IsNullOrEmpty(id))
                {
                    Debug.LogError("Bridge: DistributeUnityEvent: undefined id on eventName: " + eventName + " ev: " + ev);
                    return;
                }

                if (!idToObject.ContainsKey(id))
                {
                    Debug.LogWarning("Bridge: DistributeUnityEvent: missing id: " + id + " ev: " + ev);
                    return;
                }

                object obj = idToObject[id];
                //Debug.Log("Bridge: DistributeUnityEvent: obj: " + obj);

                BridgeObject bridgeObject = obj as BridgeObject;

                if (bridgeObject == null)
                {
                    Debug.LogError("Bridge: DistributeUnityEvent: tried to send eventName: " + eventName + " to non-BridgeObject obj: " + obj + " id: " + id + " ev: " + ev);
                    return;
                }

                bridgeObject.HandleEvent(ev);

                break;
            }
            }
        }
        ////////////////////////////////////////////////////////////////////////
        // Static Methods


        public static void AnimateData(BridgeObject bridgeObject, JArray dataArray)
        {
            GameObject go = bridgeObject.gameObject;

            if (leanTweenBridge == null)
            {
                Debug.LogError("LeanTweenBridge: AnimateData: no leanTweenBridge has been created.");
                return;
            }

            foreach (JObject data in dataArray)
            {
                LTDescr    result = null;
                GameObject target = go;

                float time = 1.0f;
                if (data.ContainsKey("time"))
                {
                    time = data.GetFloat("time");
                    if (time <= 0.0f)
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: time must be > 0. data: " + data);
                        return;
                    }
                }

                if (data.ContainsKey("target"))
                {
                    string targetPath = data.GetString("target");

                    if (targetPath == "")
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: empty targetPath");
                        return;
                    }

                    Accessor accessor = null;
                    if (!Accessor.FindAccessor(
                            bridgeObject,
                            targetPath,
                            ref accessor))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: target: can't find accessor for targetPath: " + targetPath);
                        return;
                    }

                    object obj = null;
                    if (!accessor.Get(ref obj))
                    {
                        if (!accessor.conditional)
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: target: can't get accessor: " + accessor + " targetPath: " + targetPath);
                            return;
                        }
                    }

                    GameObject goTarget = obj as GameObject;
                    if (goTarget == null)
                    {
                        Transform xform = obj as Transform;
                        if (xform != null)
                        {
                            goTarget = xform.gameObject;
                        }
                        else
                        {
                            Component component = obj as Component;
                            if (component != null)
                            {
                                goTarget = component.gameObject;
                            }
                        }
                    }

                    if (goTarget == null)
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: null targetPath: " + targetPath + " obj: " + obj);
                        return;
                    }

                    //Debug.Log("LeanTweenBridge: AnimateData: targetPath: " + targetPath + " goTarget: " + goTarget);
                    target = goTarget;
                }

                var command = (string)data.GetString("command");
                if (string.IsNullOrEmpty(command))
                {
                    Debug.LogError("LeanTweenBridge: AnimateData: missing command from data: " + data);
                    return;
                }

                switch (command)
                {
                case "init":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "play":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "cancel":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "cancelAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "pause":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "pauseAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "resume":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "resumeAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "sequence":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "value":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "move":
                case "moveLocal":
                case "moveSpline":
                case "moveSplineLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (data.ContainsKey("position"))
                    {
                        Vector3 position = Vector3.zero;
                        if (!Bridge.mainBridge.ConvertToType <Vector3>(data["position"], ref position))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: position must be a Vector3. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, position, time);
                            break;

                        case "moveLocal":
                            result = LeanTween.moveLocal(target, position, time);
                            break;

                        case "moveSpline":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: position not supported for " + command + ". data: " + data);
                            return;
                        }
                    }
                    else if (data.ContainsKey("transform"))
                    {
                        Transform xform = null;

                        string path = data.GetString("transform");

                        Accessor accessor = null;
                        if (!Accessor.FindAccessor(
                                bridgeObject,
                                path,
                                ref accessor))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: transform must be a path. path: " + path + " data: " + data);
                            return;
                        }
                        object val = null;
                        if (!accessor.Get(ref val) ||
                            (val == null))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: error getting path to transform. path: " + path + " data: " + data);
                            return;
                        }

                        xform = val as Transform;

                        if (xform == null)
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: path does not point to transform. path: " + path + " data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, xform, time);
                            break;

                        case "moveLocal":
                        case "moveSpline":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: transform not supported for " + command + ". data: " + data);
                            return;
                        }
                    }
                    else if (data.ContainsKey("path"))
                    {
                        Vector3[] path = null;
                        if (!Bridge.mainBridge.ConvertToType <Vector3[]>(data["path"], ref path))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: path must be an Vector3[]. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, path, time);
                            break;

                        case "moveLocal":
                            result = LeanTween.moveLocal(target, path, time);
                            break;

                        case "moveSpline":
                            result = LeanTween.moveSpline(target, path, time);
                            break;

                        case "moveSplineLocal":
                            result = LeanTween.moveSplineLocal(target, path, time);
                            break;
                        }
                    }
                    else if (data.ContainsKey("spline"))
                    {
                        LTSpline spline = null;
                        if (!Bridge.mainBridge.ConvertToType <LTSpline>(data["spline"], ref spline))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: spline must be a LTSpline. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "moveSpline":
                            result = LeanTween.moveSpline(target, spline, time);
                            break;

                        case "move":
                        case "moveLocal":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: spline not supported for " + command + ". data: " + data);
                            break;
                        }
                    }
                    else
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: command: " + command + " should contain position, transform, path or spline. data: " + data);
                        return;
                    }

                    break;

                case "moveX":
                case "moveY":
                case "moveZ":

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to parameter. data: " + data);
                        return;
                    }

                    float moveTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "moveX":
                        result = LeanTween.moveX(target, moveTo, time);
                        break;

                    case "moveY":
                        result = LeanTween.moveY(target, moveTo, time);
                        break;

                    case "moveZ":
                        result = LeanTween.moveZ(target, moveTo, time);
                        break;
                    }

                    break;

                case "rotate":
                case "rotateLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 rotateTo = Vector3.zero;
                    if (!Bridge.mainBridge.ConvertToType <Vector3>(data["to"], ref rotateTo))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to must be an Vector3. data: " + data);
                        return;
                    }

                    switch (command)
                    {
                    case "rotate":
                        result = LeanTween.rotate(target, rotateTo, time);
                        break;

                    case "rotateLocal":
                        result = LeanTween.rotateLocal(target, rotateTo, time);
                        break;
                    }

                    break;

                case "rotateX":
                case "rotateY":
                case "rotateZ":

                    //Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    float rotateToValue = data.GetFloat("to");

                    switch (command)
                    {
                    case "rotateX":
                        result = LeanTween.rotateX(target, rotateToValue, time);
                        break;

                    case "rotateY":
                        result = LeanTween.rotateY(target, rotateToValue, time);
                        break;

                    case "rotateZ":
                        result = LeanTween.rotateZ(target, rotateToValue, time);
                        break;
                    }

                    break;

                case "rotateAround":
                case "rotateAroundLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("axis"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing axis. data: " + data);
                        return;
                    }

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 rotateAroundAxis = Vector3.zero;
                    if (!Bridge.mainBridge.ConvertToType <Vector3>(data["axis"], ref rotateAroundAxis))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to must be an Vector3. data: " + data);
                        return;
                    }

                    float rotateAroundTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "rotateAround":
                        result = LeanTween.rotateAround(target, rotateAroundAxis, rotateAroundTo, time);
                        break;

                    case "rotateLocalLocal":
                        result = LeanTween.rotateAroundLocal(target, rotateAroundAxis, rotateAroundTo, time);
                        break;
                    }

                    break;

                case "scale":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 to      = Vector3.one;
                    JToken  toToken = data["to"];
                    if (toToken.IsNumber())
                    {
                        float s = (float)toToken;
                        to = new Vector3(s, s, s);
                    }
                    else if (toToken.IsObject())
                    {
                        if (!Bridge.mainBridge.ConvertToType <Vector3>(toToken, ref to))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: error converting to object to Vector3. data: " + data);
                            return;
                        }
                    }
                    else
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to should be number or object. toToken: " + toToken + " " + toToken.Type + " data: " + data);
                        return;
                    }

                    result = LeanTween.scale(target, to, time);

                    break;

                case "scaleX":
                case "scaleY":
                case "scaleZ":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    float scaleTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "scaleX":
                        result = LeanTween.scaleX(target, scaleTo, time);
                        break;

                    case "scaleY":
                        result = LeanTween.scaleY(target, scaleTo, time);
                        break;

                    case "scaleZ":
                        result = LeanTween.scaleZ(target, scaleTo, time);
                        break;
                    }

                    break;

                case "size":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    // TODO: handle RectTransform but not GameObject
                    break;

                case "alpha":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "color":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "colorText":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                default:
                    Debug.LogError("LeanTweenBridge: AnimateData: unknown command: " + command + " in data: " + data);
                    return;
                }

                if (result != null)
                {
/*
 *              pause
 *              resume
 *              axis
 *              delay
 *              direction
 *              ease
 *              from
 *              ignoreTimeScale
 *              loopClamp
 *              loopOnce
 *              loopPingPong
 *              onComplete
 *              onCompleteOnRepeat
 *              onCompleteOnStart
 *              onCompleteParam
 *              onStart
 *              onUpdate
 *              onUpdateParam
 *              orientToPath
 *              orientToPath2d
 *              overshoot
 *              passed
 *              period
 *              point
 *              recursive
 *              repeat
 *              scale
 *              speed
 *              time
 *              to
 *              useFrames
 *              updateNow
 */
                }
            }
        }
        public static void TrackPointer()
        {
            if ((!EventSystem.current) ||
                (pointerFrameCount == Time.frameCount))
            {
                return;
            }

            mouseRaycastHitBridgeObject           = null;
            mouseRaycastHitBridgeObjectID         = null;
            mouseRaycastHitColliderBridgeObject   = null;
            mouseRaycastHitColliderBridgeObjectID = null;

            pointerFrameCount = Time.frameCount;

            mousePosition        = Input.mousePosition;
            mousePositionChanged = mousePosition != mousePositionLast;

            screenSize =
                new Vector2(
                    Screen.width,
                    Screen.height);
            screenPosition =
                new Vector2(
                    mousePosition.x - (screenSize.x * 0.5f),
                    mousePosition.y - (screenSize.y * 0.5f));

            PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current);

            eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            List <RaycastResult> results = new List <RaycastResult>();

            EventSystem.current.RaycastAll(eventDataCurrentPosition, results);

#if false
            foreach (RaycastResult result in results)
            {
                Debug.Log("Tracker: TrackPointer: RaycastAll result: " + result + " " + result.gameObject);
            }
#endif

            isPointerOverUIObject = results.Count > 0;

            mouseRay =
                Camera.main.ScreenPointToRay(
                    mousePosition);

            mouseRaycastResult =
                Physics.Raycast(
                    mouseRay,
                    out mouseRaycastHit,
                    mouseRayMaxDistance,
                    mouseRayLayerMask,
                    mouseRayQueryTriggerInteraction);

            //Debug.Log("Tracker: TrackMousePosition: mouseRaycastResult: " + mouseRaycastResult + " mouseRaycastHitPoint: " + mouseRaycastHit.point.x + " " + mouseRaycastHit.point.y + " " + mouseRaycastHit.point.z);

            if (!mouseRaycastResult)
            {
            }
            else
            {
                Vector3 cameraPosition = Camera.main.transform.position;
                Vector3 offset         = cameraPosition - mouseRaycastHit.point;
                offset.y = 0.0f;
                float direction =
                    (offset == Vector3.zero)
                    ? 0.0f
                    : (180.0f + (Mathf.Atan2(offset.x, offset.z) * Mathf.Rad2Deg));
                mouseRaycastHitPointFaceCameraRotation =
                    Quaternion.Euler(0.0f, direction, 0.0f);

                mouseRaycastHitBridgeObject = null;
                Transform xform = mouseRaycastHit.transform;
                while (xform != null)
                {
                    mouseRaycastHitBridgeObject = xform.gameObject.GetComponent <BridgeObject>();

                    //Debug.Log("Tracker: xform: " + xform + " mouseRaycastHitBridgeObject: " + mouseRaycastHitBridgeObject);

                    if (mouseRaycastHitBridgeObject != null)
                    {
                        break;
                    }

                    xform = xform.parent;
                }

                mouseRaycastHitBridgeObjectID =
                    (mouseRaycastHitBridgeObject == null)
                    ? null
                    : mouseRaycastHitBridgeObject.id;

                mouseRaycastHitColliderBridgeObject = null;
                xform = mouseRaycastHit.collider.transform;
                while (xform != null)
                {
                    mouseRaycastHitColliderBridgeObject = xform.gameObject.GetComponent <BridgeObject>();

                    if (mouseRaycastHitColliderBridgeObject != null)
                    {
                        break;
                    }

                    xform = xform.parent;
                }

                mouseRaycastHitColliderBridgeObjectID =
                    (mouseRaycastHitColliderBridgeObject == null)
                    ? null
                    : mouseRaycastHitColliderBridgeObject.id;

                //Debug.Log("Tracker: TrackMousePosition: mouseRaycastHitBridgeObjectID: " + mouseRaycastHitBridgeObjectID + " mouseRaycastHitBridgeObject: " + mouseRaycastHitBridgeObject + " mouseRaycastHitColliderBridgeObject: " + mouseRaycastHitColliderBridgeObject + " mouseRaycastHitColliderBridgeObjectID: " + mouseRaycastHitColliderBridgeObject + " xform: " + xform);
            }
        }