public static ShotItem GenerateShotItem(Shot shot) { GameObject root = new GameObject("shotItem"); ShotItem shotItem = root.AddComponent <ShotItem>(); root.layer = LayerMask.NameToLayer("CameraHidden"); // Set the item invisible in order to hide it while it is not added into // a list. We will activate it after it is added root.transform.localScale = Vector3.zero; float cx = 0.0f; // // ACTIVE CAMERA Button // UILabel currentShotLabel = UILabel.Create(new UILabel.CreateLabelParams { parent = root.transform, widgetName = "CurrentShotLabel", relativeLocation = new Vector3(0, 0, -UIButton.default_thickness), width = 0.01f, height = 0.03f, margin = 0.001f, material = UIUtils.LoadMaterial("UIBase"), selectedColor = UIOptions.FocusColorVar, caption = "", }); currentShotLabel.SetLightLayer(3); cx += 0.01f; // // ENABLE Checkbox // UICheckbox shotEnabledCheckbox = UICheckbox.Create(new UICheckbox.CreateParams { parent = root.transform, widgetName = "ShotEnabledCheckbox", relativeLocation = new Vector3(cx, 0, -UICheckbox.default_thickness), width = 0.03f, height = 0.03f, content = UICheckbox.CheckboxContent.CheckboxOnly, margin = 0.001f, material = UIUtils.LoadMaterial("UIBase"), }); shotEnabledCheckbox.SetLightLayer(3); cx += 0.03f; // // SHOT NAME Label // UILabel shotNameLabel = UILabel.Create(new UILabel.CreateLabelParams { parent = root.transform, widgetName = "ShotNameLabel", relativeLocation = new Vector3(cx, 0, -UIButton.default_thickness), width = 0.15f, height = 0.020f, margin = 0.001f, material = UIUtils.LoadMaterial("UIBase"), }); shotNameLabel.SetLightLayer(3); UIUtils.SetTMProStyle(shotNameLabel.gameObject); // // CAMERA NAME Label // UILabel cameraNameLabel = UILabel.Create(new UILabel.CreateLabelParams { parent = root.transform, widgetName = "CameraNameLabel", relativeLocation = new Vector3(cx, -0.020f, -UIButton.default_thickness), width = 0.15f, height = 0.01f, margin = 0.001f, fgcolor = UIOptions.Instance.attenuatedTextColor, material = UIUtils.LoadMaterial("UIBase"), }); cameraNameLabel.SetLightLayer(3); UIUtils.SetTMProStyle(cameraNameLabel.gameObject, alignment: TextAlignmentOptions.BottomRight); cx += 0.15f; // Start frame button UIButton startFrameButton = UIButton.Create(new UIButton.CreateButtonParams { parent = root.transform, widgetName = "StartFrameButton", relativeLocation = new Vector3(cx, 0, -UIButton.default_thickness), width = 0.02f, height = 0.03f, icon = UIUtils.LoadIcon("next"), buttonContent = UIButton.ButtonContent.ImageOnly, margin = 0.001f, }); startFrameButton.SetLightLayer(3); cx += 0.02f; // START: Add UISpinner UISpinner startFrameSpinner = UISpinner.Create(new UISpinner.CreateArgs { parent = root.transform, widgetName = "StartFrame", relativeLocation = new Vector3(cx, 0, -UISpinner.default_thickness), width = 0.055f, height = 0.03f, visibility_type = UISpinner.TextAndValueVisibilityType.ShowValueOnly, value_type = UISpinner.SpinnerValueType.Int, min_spinner_value = 0, max_spinner_value = 10000, cur_spinner_value = shot.start, spinner_value_rate = 30, spinner_value_rate_ray = 30, margin = 0.001f, }); startFrameSpinner.baseColor.useConstant = true; startFrameSpinner.baseColor.constant = UIOptions.BackgroundColor; startFrameSpinner.selectedColor.useConstant = true; startFrameSpinner.selectedColor.constant = UIOptions.SelectedColor; startFrameSpinner.SetLightLayer(3); UIUtils.SetTMProStyle(startFrameSpinner.gameObject); cx += 0.055f; // END: Add UISpinner UISpinner endFrameSpinner = UISpinner.Create(new UISpinner.CreateArgs { parent = root.transform, widgetName = "EndFrame", relativeLocation = new Vector3(cx, 0, -UISpinner.default_thickness), width = 0.055f, height = 0.03f, visibility_type = UISpinner.TextAndValueVisibilityType.ShowValueOnly, value_type = UISpinner.SpinnerValueType.Int, min_spinner_value = 0, max_spinner_value = 10000, cur_spinner_value = shot.end, spinner_value_rate = 30, spinner_value_rate_ray = 30, margin = 0.001f, }); endFrameSpinner.baseColor.useConstant = true; endFrameSpinner.baseColor.constant = UIOptions.BackgroundColor; endFrameSpinner.selectedColor.useConstant = true; endFrameSpinner.selectedColor.constant = UIOptions.SelectedColor; endFrameSpinner.SetLightLayer(3); UIUtils.SetTMProStyle(endFrameSpinner.gameObject); cx += 0.055f; // End frame button UIButton endFrameButton = UIButton.Create(new UIButton.CreateButtonParams { parent = root.transform, widgetName = "EndFrameButton", relativeLocation = new Vector3(cx, 0, -UIButton.default_thickness), width = 0.02f, height = 0.03f, icon = UIUtils.LoadIcon("prev"), buttonContent = UIButton.ButtonContent.ImageOnly, margin = 0.001f, }); endFrameButton.SetLightLayer(3); cx += 0.02f; // RANGE: Add UILabel UILabel frameRangeLabel = UILabel.Create(new UILabel.CreateLabelParams { parent = root.transform, widgetName = "FrameRange", relativeLocation = new Vector3(cx, 0, -UILabel.default_thickness), width = 0.04f, height = 0.03f, margin = 0.001f, material = UIUtils.LoadMaterial("UIBase"), }); frameRangeLabel.baseColor.useConstant = true; frameRangeLabel.baseColor.constant = UIOptions.BackgroundColor; frameRangeLabel.selectedColor.useConstant = true; frameRangeLabel.selectedColor.constant = UIOptions.SelectedColor; frameRangeLabel.SetLightLayer(3); UIUtils.SetTMProStyle(frameRangeLabel.gameObject, alignment: TextAlignmentOptions.Center); cx += 0.04f; // Set camera UIButton setCameraButton = UIButton.Create(new UIButton.CreateButtonParams { parent = root.transform, widgetName = "SetCameraButton", relativeLocation = new Vector3(cx, 0, -UIButton.default_thickness), width = 0.03f, height = 0.03f, icon = UIUtils.LoadIcon("icon-camera"), buttonContent = UIButton.ButtonContent.ImageOnly, margin = 0.001f, }); setCameraButton.isCheckable = true; setCameraButton.checkedSprite = UIUtils.LoadIcon("icon-camera"); setCameraButton.checkedColor.useConstant = false; setCameraButton.checkedColor.constant = UIOptions.FocusColor; setCameraButton.checkedColor.reference = UIOptions.FocusColorVar; setCameraButton.baseSprite = UIUtils.LoadIcon("icon-camera"); setCameraButton.SetLightLayer(3); // Link widgets to the item script. shotItem.currentShotLabel = currentShotLabel; shotItem.shotEnabledCheckbox = shotEnabledCheckbox; shotItem.shotNameLabel = shotNameLabel; shotItem.cameraNameLabel = cameraNameLabel; shotItem.startFrameSpinner = startFrameSpinner; shotItem.startFrameButton = startFrameButton; shotItem.frameRangeLabel = frameRangeLabel; shotItem.endFrameSpinner = endFrameSpinner; shotItem.endFrameButton = endFrameButton; shotItem.setCameraButton = setCameraButton; shotItem.SetShot(shot); return(shotItem); }
private const int RT_DEPTH = 0;//24; public override GameObject CreateInstance(GameObject source, Transform parent = null, bool isPrefab = false) { GameObject newCamera = GameObject.Instantiate(source, parent); VRInput.DeepSetLayer(newCamera, "CameraHidden"); newCamera.GetComponentInChildren <CameraController>(true).CopyParameters(source.GetComponentInChildren <CameraController>(true)); if (!GlobalState.Settings.DisplayGizmos) { GlobalState.SetGizmoVisible(newCamera, false); } // Add UI if (isPrefab) { Transform uiRoot = newCamera.transform.Find("Rotate/Name"); if (null == uiRoot.Find("Name")) { UILabel nameLabel = UILabel.Create(new UILabel.CreateLabelParams { parent = uiRoot, widgetName = "Name", caption = "Camera", width = 1.4f, height = 0.25f, labelContent = UILabel.LabelContent.TextOnly, }); { TextMeshProUGUI text = nameLabel.gameObject.GetComponentInChildren <TextMeshProUGUI>(); text.enableAutoSizing = true; text.fontSizeMin = 6f; text.fontSizeMax = 72f; text.alignment = TextAlignmentOptions.Center; } nameLabel.baseColor.useConstant = true; nameLabel.baseColor.constant = new Color(0, 0, 0, 0); nameLabel.SetLightLayer(2); } uiRoot = newCamera.transform.Find("Rotate/UI"); if (null == uiRoot.Find("Focal")) { // Focal slider UISlider focalSlider = UISlider.Create(new UISlider.CreateArgs { parent = uiRoot, widgetName = "Focal", caption = "Focal", currentValue = 35f, sliderBegin = 0.15f, sliderEnd = 0.86f, relativeLocation = new Vector3(-0.30f, -0.03f, -UISlider.default_thickness), width = 0.3f, height = 0.02f, railMargin = 0.002f, knobRadius = 0.007f }); focalSlider.DataCurve = GlobalState.Settings.focalCurve; focalSlider.SetLightLayer(2); } // In front button if (null == uiRoot.Find("InFront")) { UIButton inFrontButton = UIButton.Create(new UIButton.CreateButtonParams { parent = uiRoot, widgetName = "InFront", caption = "Always in Front", buttonContent = UIButton.ButtonContent.ImageOnly, icon = UIUtils.LoadIcon("back"), width = 0.02f, height = 0.02f, iconMarginBehavior = UIButton.IconMarginBehavior.UseIconMargin, iconMargin = 0.002f, relativeLocation = new Vector3(-0.30f, -0.005f, -UIButton.default_thickness) }); inFrontButton.isCheckable = true; inFrontButton.baseSprite = UIUtils.LoadIcon("back"); inFrontButton.checkedSprite = UIUtils.LoadIcon("front"); inFrontButton.SetLightLayer(2); } // Touch screen uiRoot = newCamera.transform.Find("Rotate/CameraPreview"); UITouchScreen touchScreen = UITouchScreen.Create(new UITouchScreen.CreateTouchScreenParams { parent = uiRoot, width = 1f, height = 1f, thickness = 0.01f, relativeLocation = new Vector3(-0.5f, 0.5f, -0.03f) }); touchScreen.SetLightLayer(2); touchScreen.gameObject.SetActive(false); // Focus button uiRoot = newCamera.transform.Find("Rotate/UI"); UIButton focusButton = UIButton.Create(new UIButton.CreateButtonParams { parent = uiRoot, widgetName = "FocusButton", caption = "Enable Touch Screen Focus", buttonContent = UIButton.ButtonContent.ImageOnly, icon = UIUtils.LoadIcon("dof"), width = 0.02f, height = 0.02f, iconMarginBehavior = UIButton.IconMarginBehavior.UseIconMargin, iconMargin = 0.002f, relativeLocation = new Vector3(-0.27f, -0.005f, -UIButton.default_thickness) }); focusButton.isCheckable = true; focusButton.baseSprite = UIUtils.LoadIcon("dof"); focusButton.checkedSprite = UIUtils.LoadIcon("dof"); focusButton.SetLightLayer(2); // Video output button uiRoot = newCamera.transform.Find("Rotate/UI"); UIButton videoOutputButton = UIButton.Create(new UIButton.CreateButtonParams { parent = uiRoot, widgetName = "VideoOutputButton", caption = "Outputs camera to video file", buttonContent = UIButton.ButtonContent.ImageOnly, icon = UIUtils.LoadIcon("record_video"), width = 0.02f, height = 0.02f, iconMarginBehavior = UIButton.IconMarginBehavior.UseIconMargin, iconMargin = 0.002f, relativeLocation = new Vector3(-0.02f, -0.005f, -UIButton.default_thickness) }); videoOutputButton.isCheckable = true; videoOutputButton.baseSprite = UIUtils.LoadIcon("record_video"); videoOutputButton.checkedSprite = UIUtils.LoadIcon("record_video"); videoOutputButton.SetLightLayer(2); // Snapshot button uiRoot = newCamera.transform.Find("Rotate/UI"); UIButton snapshotButton = UIButton.Create(new UIButton.CreateButtonParams { parent = uiRoot, widgetName = "SnapshotButton", caption = "Outputs camera to image file", buttonContent = UIButton.ButtonContent.ImageOnly, icon = UIUtils.LoadIcon("snapshot"), width = 0.02f, height = 0.02f, iconMarginBehavior = UIButton.IconMarginBehavior.UseIconMargin, iconMargin = 0.002f, relativeLocation = new Vector3(-0.05f, -0.005f, -UIButton.default_thickness) }); snapshotButton.SetLightLayer(2); } return(newCamera); }