Пример #1
0
    private void DetectGlowObjects()
    {
        if (!shouldObserveOutlines)
        {
            return;
        }
        Outline      newGlowObject      = null;
        bool         detectedGlowObject = false;
        bool         hit3D     = Physics.Raycast(cam.transform.position, cam.transform.forward, out RaycastHit hitInfo, 20.0f, Physics.DefaultRaycastLayers);
        RaycastHit2D hitInfo2D = Physics2D.Raycast(cam.transform.position, cam.transform.forward, 20.0f);

        if (hit3D)
        {
            Outline glowObject = hitInfo.transform.gameObject.GetComponent <Outline>();
            if (glowObject == null && hitInfo.transform.childCount > 0)
            {
                glowObject = hitInfo.transform.GetChild(0).gameObject.GetComponent <Outline>();
            }
            if (glowObject != null)
            {
                newGlowObject      = glowObject;
                detectedGlowObject = true;
            }
        }
        else if (hitInfo2D)
        {
            Outline glowObject = hitInfo2D.transform.gameObject.GetComponent <Outline>();
            if (glowObject != null)
            {
                newGlowObject      = glowObject;
                detectedGlowObject = true;
            }
        }
        if (currentObject != newGlowObject)
        {
            if (currentObject != null)
            {
                currentObject.eraseRenderer = true;
            }
            timeLookingAtCurrentObject = 0f;
            currentObject = null;
            animator.SetElapsedTime(timeLookingAtCurrentObject);
        }

        if (detectedGlowObject)
        {
            newGlowObject.eraseRenderer = false;
            timeLookingAtCurrentObject += Time.deltaTime;
            animator.SetElapsedTime(timeLookingAtCurrentObject);
            currentObject = newGlowObject;
        }
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     timeElapsed += Time.deltaTime;
     if (clock != null && timeElapsed < 10f)
     {
         if (generated)
         {
             timeElapsed = 10f;
         }
         clock.SetElapsedTime(timeElapsed);
     }
 }