Ejemplo n.º 1
0
    //-------------------------------------------------------------------------------------------------------------------------
    // Linked Scripts

    #region LinkedScripts

    /// <summary> Check if an object has a SG_HandModelInfo component and assign it to the info parameter. </summary>
    /// <param name="obj"></param>
    /// <param name="info"></param>
    public static void CheckForHandInfo(Transform obj, ref SG_HandModelInfo info)
    {
        if (info == null)
        {
            info = obj.gameObject.GetComponent <SG_HandModelInfo>();
        }                                       //check selft
        if (info == null && obj.parent != null) //check children
        {
            info = obj.parent.GetComponentInChildren <SG_HandModelInfo>();
        }
    }
Ejemplo n.º 2
0
    /// <summary> Link relevant scripts to this trackedHand, if they have not been assinged yet. </summary>
    protected void CheckForScripts()
    {
        if (this.hardware == null)
        {
            this.hardware = this.gameObject.GetComponent <SG_SenseGloveHardware>();
        }
        if (this.handModel == null)
        {
            this.handModel = this.GetComponentInChildren <SG_HandModelInfo>();
        }

        if (this.grabScript == null)
        {
            this.grabScript = this.GetComponentInChildren <SG_GrabScript>();
        }
        if (this.feedbackScript == null)
        {
            this.feedbackScript = this.GetComponentInChildren <SG_HandFeedback>();
        }
        if (this.handAnimation == null)
        {
            this.handAnimation = this.GetComponentInChildren <SG_HandAnimator>();
        }

        //Since both RB and PhysicsTrackingLayers have the same component, assing whichever one we haven't done yet.
        if (this.rigidBodyLayer == null || this.physicsTrackingLayer == null)
        {
            SG_HandRigidBodies[] components = this.GetComponentsInChildren <SG_HandRigidBodies>();
            for (int i = 0; i < components.Length; i++)
            {
                if (this.rigidBodyLayer == null && //we don't yet have a RigidBody Layer
                    (this.physicsTrackingLayer == null || !GameObject.ReferenceEquals(this.physicsTrackingLayer.gameObject, components[i].gameObject)))
                {
                    rigidBodyLayer = components[i];
                }
                if (this.physicsTrackingLayer == null && //we don't yet have a RigidBody Layer
                    (this.rigidBodyLayer == null || !GameObject.ReferenceEquals(this.rigidBodyLayer.gameObject, components[i].gameObject)))
                {
                    physicsTrackingLayer = components[i];
                }
            }
        }
    }