que tal este codigo,es correcto?: "using System.Collections; using…
- User
que tal este codigo,es correcto?: "using System.Collections; using System.Collections.Generic; using DG.Tweening; using UnityEngine;
public class BotonManager : MonoBehaviour { private AudioSource fuenteAudio; private float screenHeight; private float screenWidth; private float moveTime = 1f;
private void Awake() { fuenteAudio = GetComponent<AudioSource>(); screenHeight = Camera.main.orthographicSize * 2; screenWidth = screenHeight * Screen.width / Screen.height; } private void OnMouseDown() { float buttonWidth = GetComponent<SpriteRenderer>().bounds.size.x; float buttonHeight = GetComponent<SpriteRenderer>().bounds.size.y; var minX = -screenWidth / 2 + buttonWidth / 2; var maxX = screenWidth / 2 - buttonWidth / 2; var minY = -screenHeight / 2 + buttonHeight / 2; var maxY = screenHeight / 2 - buttonHeight / 2; float randomX = Random.Range(minX, maxX); float randomY = Random.Range(minY, maxY); //Creamos un vector 2D con las coordenadas aleatorias generadas var randomPosition = new Vector2(randomX, randomY); //Comprobamos que la posición no se salga de la pantalla randomPosition.x = Mathf.Clamp(randomPosition.x, -screenWidth / 2, screenWidth / 2); randomPosition.y = Mathf.Clamp(randomPosition.y, -screenHeight / 2, screenHeight / 2); Ease easeRandom = (Ease) Random.Range(0, 30); Ease easeRandom2 = (Ease) Random.Range(0, 30); Debug.Log("easeRandom: " + easeRandom); Sequence sequence = DOTween.Sequence(); sequence.Append(transform.DOMove(randomPosition, moveTime).SetEase(easeRandom).SetId(transform)); sequence.Join(transform.DORotate(new Vector3(0, 360, 0), moveTime, RotateMode.FastBeyond360) .SetEase(easeRandom2).SetId(transform)) .OnPlay(() => fuenteAudio.Play()) .OnComplete(() => fuenteAudio.Stop()); }}"
- Assistant
- User
porque me da este error en jetbrains rider?: "Cannot resolve symbol 'MonoBehaviour'"
- Assistant