예제 #1
0
    protected void SetNewHands()
    {
        HandController controller = GetComponent <HandController>();

        controller.leftGraphicsModel  = leftHands[hand_index_];
        controller.rightGraphicsModel = rightHands[hand_index_];
        controller.DestroyAllHands();
    }
    void Update()
    {
        if (Time.timeSinceLevelLoad < startTime)
        {
            return;
        }

        HandController controller = GetComponent <HandController>();

        if (!played_ && controller.IsConnected())
        {
            controller.enabled = true;
            controller.StopRecording();
            controller.PlayRecording();
            played_ = true;
        }

        float progress = controller.GetRecordingProgress();

        if (live_controller_ != null &&
            live_controller_.GetAllGraphicsHands().Length > 0 &&
            onlyPlayIfNoHands)
        {
            force_fade_ *= forceFadeDecay;
        }
        else if (exiting_)
        {
            force_fade_ *= forceFadeDecay;
        }
        else
        {
            force_fade_ = 1.0f - forceFadeDecay * (1.0f - force_fade_);
        }

        if (force_fade_ < 0.01f)
        {
            progress = 1.0f;
        }

        if (progress >= 1.0f)
        {
            controller.DestroyAllHands();
            for (int i = 0; i < additionalObjects.Length; ++i)
            {
                Destroy(additionalObjects[i].gameObject);
            }
            gameObject.SetActive(false);
            return;
        }

        float alpha = force_fade_ * maxTransparency;

        if (progress < fadeInLength)
        {
            alpha *= progress / fadeInLength;
        }
        else if (1.0f - progress < fadeOutLength)
        {
            alpha *= (1.0f - progress) / fadeOutLength;
        }

        HandModel[] hands = controller.GetAllGraphicsHands();
        foreach (HandModel hand in hands)
        {
            Renderer[] renderers = hand.GetComponentsInChildren <Renderer>();
            for (int i = 0; i < renderers.Length; ++i)
            {
                SetAlphaOfRenderer(renderers[i], alpha);
            }
            for (int i = 0; i < additionalObjects.Length; ++i)
            {
                SetAlphaOfRenderer(additionalObjects[i], alpha);
            }
        }
    }