Exemple #1
0
 public CollisionNodeInfo(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit)
 {
     this.hitNode          = hitNode;
     collider              = colliderObj;
     collision             = collisionObj;
     controllerColliderHit = cchit;
 }
 public CollisionNodeInfo(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit)
 {
     this.hitNode = hitNode;
     collider = colliderObj;
     collision = collisionObj;
     controllerColliderHit = cchit;
 }
        GameObject createColliderObject(string newColName, Transform parentTransform, string nodePath)
        {
            // Create the GameObject itself
            GameObject newColObj = new GameObject(newColName);

            // Add the Box Collider and give it some initial properties
            newColObj.AddComponent <BoxCollider>();
            BoxCollider boxCollider = newColObj.GetComponent <BoxCollider>();

            boxCollider.size      = new Vector3(1.0f, 1.0f, 10.0f);
            boxCollider.isTrigger = true;

            // Add the event delegate component
            CollisionNodeToggler nodeToggler = newColObj.AddComponent <CollisionNodeToggler>();

            nodeToggler.componentPath = nodePath;

            newColObj.transform.parent = parentTransform;

            return(newColObj);
        }
        void nodeCollisionHandler(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit, NodeCollisionEvent evt)
        {
            if (sendMessage)
            {
                // Inform any listening components that collision entry occured.
                switch (evt)
                {
                case NodeCollisionEvent.OnMouseEnter:
                    SendMessage("OnComponentMouseEnter", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnMouseOver:
                    SendMessage("OnComponentMouseOver", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnMouseExit:
                    SendMessage("OnComponentMouseExit", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnMouseDown:
                    SendMessage("OnComponentMouseDown", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnMouseUp:
                    SendMessage("OnComponentMouseUp", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnMouseUpAsButton:
                    SendMessage("OnComponentMouseUpAsButton", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnMouseDrag:
                    SendMessage("OnComponentMouseDrag", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnTriggerEnter:
                    SendMessage("OnComponentTriggerEnter", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnTriggerExit:
                    SendMessage("OnComponentTriggerExit", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnTriggerStay:
                    SendMessage("OnComponentTriggerStay", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnCollisionEnter:
                    SendMessage("OnComponentCollisionEnter", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnCollisionExit:
                    SendMessage("OnComponentCollisionExit", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnCollisionStay:
                    SendMessage("OnComponentCollisionStay", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;

                case NodeCollisionEvent.OnControllerColliderHit:
                    SendMessage("OnComponentControllerColliderHit", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                    break;
                }
            }
            //else
            {
                switch (evt)
                {
                case NodeCollisionEvent.OnMouseEnter:
                    OnComponentMouseEnter(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnMouseOver:
                    OnComponentMouseOver(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnMouseExit:
                    OnComponentMouseExit(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnMouseDown:
                    OnComponentMouseDown(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnMouseUp:
                    OnComponentMouseUp(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnMouseUpAsButton:
                    OnComponentMouseUpAsButton(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnMouseDrag:
                    OnComponentMouseDrag(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnTriggerEnter:
                    OnComponentTriggerEnter(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnTriggerExit:
                    OnComponentTriggerExit(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnTriggerStay:
                    OnComponentTriggerStay(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnCollisionEnter:
                    OnComponentCollisionEnter(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnCollisionExit:
                    OnComponentCollisionExit(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnCollisionStay:
                    OnComponentCollisionStay(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;

                case NodeCollisionEvent.OnControllerColliderHit:
                    OnComponentControllerColliderHit(new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                    break;
                }
            }
        }
        void nodeCollisionHandler(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit, NodeCollisionEvent evt)
        {
            if (sendMessage)
            {
                // Inform any listening components that collision entry occured.
                switch (evt)
                {
                    case NodeCollisionEvent.OnMouseEnter:
                        SendMessage("OnComponentMouseEnter", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnMouseOver:
                        SendMessage("OnComponentMouseOver", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnMouseExit:
                        SendMessage("OnComponentMouseExit", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnMouseDown:
                        SendMessage("OnComponentMouseDown", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnMouseUp:
                        SendMessage("OnComponentMouseUp", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnMouseUpAsButton:
                        SendMessage("OnComponentMouseUpAsButton", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnMouseDrag:
                        SendMessage("OnComponentMouseDrag", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnTriggerEnter:
                        SendMessage("OnComponentTriggerEnter", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnTriggerExit:
                        SendMessage("OnComponentTriggerExit", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnTriggerStay:
                        SendMessage("OnComponentTriggerStay", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnCollisionEnter:
                        SendMessage("OnComponentCollisionEnter", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnCollisionExit:
                        SendMessage("OnComponentCollisionExit", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnCollisionStay:
                        SendMessage("OnComponentCollisionStay", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;

                    case NodeCollisionEvent.OnControllerColliderHit:
                        SendMessage("OnComponentControllerColliderHit", new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit), SendMessageOptions.DontRequireReceiver);
                        break;
                }
            }
            //else
            {
                switch (evt)
                {
                    case NodeCollisionEvent.OnMouseEnter:
                        OnComponentMouseEnter( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnMouseOver:
                        OnComponentMouseOver( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnMouseExit:
                        OnComponentMouseExit( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnMouseDown:
                        OnComponentMouseDown( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnMouseUp:
                        OnComponentMouseUp( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnMouseUpAsButton:
                        OnComponentMouseUpAsButton( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnMouseDrag:
                        OnComponentMouseDrag( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnTriggerEnter:
                        OnComponentTriggerEnter( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnTriggerExit:
                        OnComponentTriggerExit( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnTriggerStay:
                        OnComponentTriggerStay( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnCollisionEnter:
                        OnComponentCollisionEnter( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnCollisionExit:
                        OnComponentCollisionExit( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnCollisionStay:
                        OnComponentCollisionStay( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;

                    case NodeCollisionEvent.OnControllerColliderHit:
                        OnComponentControllerColliderHit( new CollisionNodeInfo(hitNode, colliderObj, collisionObj, cchit));
                        break;
                }
            }
        }