void Start() { arCam = FindObjectOfType <CameraDeviceBehaviour>(); transitionBackground = transform.parent.GetComponentInParent <RawImage>(); transitionBackground.enabled = false; snapshooter = FindObjectOfType <SnapshotMaker>(); // загрузка спрайтов для разных состояний кнопки const string rotateBackSpritePath = "buttons/rotate_back"; rotateBackSprite = Resources.Load <Sprite>(rotateBackSpritePath); const string rotateFrontSpritePath = "buttons/rotate_front"; rotateFrontSprite = Resources.Load <Sprite>(rotateFrontSpritePath); image = GetComponent <UnityEngine.UI.Image>(); toggle = GetComponent <Toggle>(); toggle.onValueChanged.AddListener(delegate { // смена спрайта image.sprite = toggle.isOn ? rotateBackSprite : rotateFrontSprite; // выключение ui на время переключения камеры SetUiActive(false); // показ заглушки на время переключения камеры snapshooter.ScreenTexMade += OnCreenshotMade; snapshooter.RefreshScreenshotRenderTex(); snapshooter.Screenshoot(); // шаг 1: скриним экран, ставим на заглушку }); }
// Starts up the QCAR extension with the properties that were set in the // Unity inspector. void Start() { ResetCameraClearFlags(); mClearMaterial = new Material(Shader.Find("Diffuse")); mCameraDevice = (CameraDeviceBehaviour)FindObjectOfType( typeof(CameraDeviceBehaviour)); qcarSetHint((int) QCARHint.HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, MaxSimultaneousImageTargets); qcarSetHint((int) QCARHint.HINT_IMAGE_TARGET_MULTI_FRAME_ENABLED, MultiFrameEnabled ? 1 : 0); SetUnityVersion(); StartQCAR(); InitializeTrackables(); InitializeTrackableContainer(); InitializeVirtualButtons(); InitializeVirtualButtonContainer(); mHasStartedOnce = true; }
// Helper function to automatically create an option list of an enum object. private static CameraDeviceBehaviour.FocusMode EnumOptionList( CameraDeviceBehaviour.FocusMode setMode) { Type modeType = setMode.GetType(); // Get possible enum values. CameraDeviceBehaviour.FocusMode[] modes = (CameraDeviceBehaviour.FocusMode[])Enum.GetValues(modeType); // Setup style for list. GUIStyle optionListStyle = new GUIStyle(GUI.skin.button); optionListStyle.stretchHeight = true; optionListStyle.stretchWidth = true; // Setup style for toggles. // We use "button" style as template because default toggles are too // small. GUIStyle toggleStyle = new GUIStyle(GUI.skin.button); toggleStyle.stretchHeight = true; toggleStyle.stretchWidth = true; toggleStyle.normal.textColor = Color.gray; toggleStyle.onNormal.textColor = Color.gray; toggleStyle.focused.textColor = Color.gray; toggleStyle.onFocused.textColor = Color.gray; toggleStyle.active.textColor = Color.gray; toggleStyle.onActive.textColor = Color.gray; toggleStyle.hover.textColor = Color.gray; toggleStyle.onHover.textColor = Color.gray; // Setup style for active toggle. // Setting active values for the toggle Style does not work so we create // another style. GUIStyle activeToggleStyle = new GUIStyle(toggleStyle); activeToggleStyle.normal.textColor = Color.white; activeToggleStyle.onNormal.textColor = Color.white; activeToggleStyle.focused.textColor = Color.white; activeToggleStyle.onFocused.textColor = Color.white; activeToggleStyle.active.textColor = Color.white; activeToggleStyle.onActive.textColor = Color.white; activeToggleStyle.hover.textColor = Color.white; activeToggleStyle.onHover.textColor = Color.white; CameraDeviceBehaviour.FocusMode newMode = setMode; // We render the menu over the full screen. GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height)); GUILayout.BeginVertical(); foreach (CameraDeviceBehaviour.FocusMode mode in modes) { if (mode == setMode) { GUILayout.Toggle(true, mode.ToString(), activeToggleStyle); } else { if (GUILayout.Toggle(false, mode.ToString(), toggleStyle)) { newMode = mode; } } } GUILayout.EndVertical(); GUILayout.EndArea(); return newMode; }
void Awake() { cameraDeviceBehaviour = this; }