private void Awake() { _messageText = GetComponentInChildren <TextMeshProUGUI>(); _textFader = _messageText.GetComponent <ObjectFader>(); DisplayInitialMessage(); }
// Instance the material(s) so we don't have to worry about conflicts w/ highlighting // This script will break batching, should only be used on rare objects like crafting stations private void ForceInstanceMats() { bool allInstanced = true; #if ECO_DEV //HACK: skip fading, alternatively we need to have fader use an instanced material when it finishes ObjectFader f = GetComponent <ObjectFader>(); if (f != null) { f.FinishFade(); } #endif foreach (Material m in r.sharedMaterials) { if (!m.name.Contains("Instance")) { allInstanced = false; } } if (!allInstanced) { Material[] mats = r.materials; r.materials = mats; } instanced = true; }
//Called on the first frame void Start() { //gets component of the NPC game object myRigidBody = GetComponent <Rigidbody2D>(); fader = keyIndicator.GetComponent <ObjectFader>(); myGameSession = FindObjectOfType <GameSession>(); SetDialogueBoxActive(false); //Records original transform of dialogue box, continue text, and dialogue text dialogueBoxLocalScaleOriginal = dialogueBox.transform.localScale; dialogueTextLocalScaleOriginal = dialogueText.transform.localScale; continueTextLocalScaleOriginal = continueText.transform.localScale; }
private IEnumerator FadeOutAndDelete(GameObject o, float destroyTime) { yield return new WaitForSeconds(destroyTime); ObjectFader objectFader = o.GetComponent<ObjectFader>(); if (!objectFader) { Destroy(o); } else { objectFader.OnFadeToTransparentComplete += () => Destroy(o); objectFader.FadeToTransparent(); } }
/// <summary> /// Initializes the default values. /// </summary> public override void Awake() { base.Awake(); m_Camera = m_CameraController.gameObject.GetCachedComponent <UnityEngine.Camera>(); #if ULTIMATE_CHARACTER_CONTROLLER_VR VRCameraIdentifier vrCamera; if ((vrCamera = m_GameObject.GetComponentInChildren <VRCameraIdentifier>()) != null) { // The VR camera will be used as the main camera. m_Camera.enabled = false; m_Camera = vrCamera.GetComponent <UnityEngine.Camera>(); m_VREnabled = true; } #endif m_ObjectFader = m_CameraController.gameObject.GetComponent <ObjectFader>(); m_LookDistance = m_LookDirectionDistance; }
private void BreakOnHit() { GameObject instantiatedBrokenVersion = Instantiate(brokenVersion, transform.position, transform.rotation); OnBreak?.Invoke(instantiatedBrokenVersion); if (fadeAwayAfterBreaking) { ObjectFader objectFader = instantiatedBrokenVersion.GetComponent <ObjectFader>(); if (objectFader) { objectFader.FadeToTransparent(secondsLater: destroyInSeconds, destroyAfter: true); } } Rigidbody[] rigidbodies = instantiatedBrokenVersion.GetComponentsInChildren <Rigidbody>(); foreach (Rigidbody r in rigidbodies) { r.AddExplosionForce(explosionForce, transform.position, 1f); } Destroy(gameObject); }
private void OnCollisionEnter(Collision other) { if (!hasBeenBumped || hasHit || other.gameObject.CompareTag("Player")) { return; } noisePing.SpawnNoisePing(other); hasHit = true; UIManager.Instance.staminaBar.InstantIncreaseAwakenessBy(awakenessIncreasePercentage); OnHit?.Invoke(); if (fadeAndDestroyAfterThrow) { ObjectFader objectFader = GetComponent <ObjectFader>(); if (objectFader) { objectFader.FadeToTransparent(destroyAfterSeconds, fadeAndDestroyAfterThrow); } } }