public AngleHeightElevation GetAvailableAngleAndHeightSlot() { AngleHeightElevation angleHeightElevation = new AngleHeightElevation(); angleHeightElevation.angle = currentVideoPanelAngle; angleHeightElevation.elevation = currentVideoPanelElevation; angleHeightElevation.distance = currentVideoPanelDistance; currentVideoPanelAngle += videoPanelAngleStep; if (currentVideoPanelAngle > videoPanelMaxAngle) { currentVideoPanelAngle = 0.0f; currentVideoPanelElevation += videoPanelElevationStep; if (currentVideoPanelElevation > videoPanelMaxElevation) { currentVideoPanelDistance += videoPanelDistanceStep; currentVideoPanelElevation = videoPanelStartElevation; // Add an offset for non-zero distances int distanceIndex = Mathf.RoundToInt((currentVideoPanelDistance - videoPanelStartDistance) / videoPanelDistanceStep); currentVideoPanelAngle = (float)distanceIndex * videoPanelPerDistanceLevelOffset; } } return(angleHeightElevation); }
void Start() { if (!ignoreAutomaticPlacement) { AngleHeightElevation angleHeightElevation = playManager.GetAvailableAngleAndHeightSlot(); panelDistance = angleHeightElevation.distance; panelArc = angleHeightElevation.angle; panelY = angleHeightElevation.elevation; //Debug.Log(gameObject.name + " got distance " + panelDistance + " and arc " + panelArc + " and y " + panelY); // Position at startDistance from camera, at startArc along // a circular arc, and reorient to face the camera Vector3 planePosOffset = new Vector3(panelDistance * Mathf.Sin(panelArc * Mathf.Deg2Rad), 0.0f, panelDistance * Mathf.Cos(panelArc * Mathf.Deg2Rad)); transform.position = Camera.main.transform.position + planePosOffset; // Set default height transform.position = new Vector3(transform.position.x, panelY, transform.position.z); transform.rotation = Quaternion.LookRotation(Camera.main.transform.position - transform.position) * Quaternion.Euler(90.0f, 0.0f, 0.0f); } //// Move the highlight plane just in front of the movie texture plane //highlightPlane.position = planePosOffset + highlightPlaneDistanceOffset * (Camera.main.transform.position - transform.position); //highlightPlane.rotation = Quaternion.LookRotation(Camera.main.transform.position - transform.position) * Quaternion.Euler(90.0f, 0.0f, 0.0f); // Set material to unselected still myRenderer = GetComponent <Renderer>(); myRenderer.material = movieStillMaterial; myCollider = GetComponent <BoxCollider>(); myAudioSource = GetComponent <AudioSource>(); myAudioSource.clip = movieTexture.audioClip; // Adjust scale (keep height; scale width) float aspectRatio = (float)movieTexture.width / (float)movieTexture.height; float newWidthScale = transform.localScale.z * aspectRatio; transform.localScale = new Vector3(newWidthScale, transform.localScale.y, transform.localScale.z); }