public void OnSceneItemRemoved(ISceneItem item) { if (activeStep != null) { activeStep.Remove(item); } }
public void LoadWorkflow(string fileName = null) { string filePath = workflowDirectory + "/" + fileName; if (!File.Exists(filePath)) { return; } m_ItemRegistry.ClearRegistry(); string stringData = File.ReadAllText(filePath); WorkflowData data = JsonUtility.FromJson <WorkflowData>(stringData); foreach (WorkflowStepData stepData in data.steps) { foreach (SceneItemData itemData in stepData.items) { ISceneItem item = m_SceneItemFactory.Create(itemData); item.itemTransform.gameObject.SetActive(false); } } m_WorkflowService.SetWorkflowData(data); m_WorkflowService.StartWork(); }
public CapturePageDisplay(SceneEditingModel model, ISceneItem editing) : base(model, editing, d => d.Displays, i => i.Source.CaptureDisplay, (s, c) => s.CaptureDisplay = c) { }
public void OnEvent(SelectionChanged arg) { foreach (ISubHandle curHandle in m_Handles) { curHandle.ToggleActive(false, true); } if (arg.current == null) { target = null; gameObject.SetActive(false); return; } gameObject.SetActive(true); target = (arg.current as Draggable).GetComponent <ISceneItem>(); Vector2 size = (gameObject.transform as RectTransform).sizeDelta; size.x = target.itemTransform.localScale.x * 100; (gameObject.transform as RectTransform).sizeDelta = size; Canvas parentCanvas = (gameObject.transform as RectTransform).GetParentCanvas(); Camera parentCamera = parentCanvas.worldCamera; Vector2 screenPosition = parentCamera.WorldToScreenPoint(target.itemTransform.position); (gameObject.transform as RectTransform).anchoredPosition = screenPosition / parentCanvas.scaleFactor; }
private void OnItemRemoved(ISceneItem arg0) { if (!m_SceneItems.Contains(arg0)) { return; } m_SceneItems.Remove(arg0); }
public bool Add(ISceneItem item) { if (m_SceneItems.Contains(item)) { return(false); } m_SceneItems.Add(item); return(true); }
public ImagePage(SceneEditingModel model, ISceneItem editedItem) { _model = model; _editedItem = editedItem; AddFile = (s, b) => _ = AddResource(s, b); RefreshFromModel(); }
public bool Remove(ISceneItem item) { if (!m_SceneItems.Contains(item)) { return(true); } m_ItemRegistry.RemoveItemById(item.identifiable.identifier); return(true); }
public CapturePageWindow(SceneEditingModel model, ISceneItem editing) : base(model, editing, d => d.Windows, i => i.Source.CaptureWindow, (s, c) => s.CaptureWindow = c) { SelectSupported = model.SceneState.IsLocal; Select = () => { _ = SelectAsync(); }; }
public override void RegisterSceneItem(ISceneItem item) { if (item != null) { if (!m_mapAllSceneItem.ContainsKey(item.ItemIndex)) { m_mapAllSceneItem.Add(item.ItemIndex, item); } } }
/// <inheritdoc /> public void ClearRegistry() { foreach (KeyValuePair <int, ISceneItem> kvp in m_SceneItems) { ISceneItem sceneItem = kvp.Value; sceneItem.itemTransform.SetParent(null); itemRemoved.Invoke(sceneItem); GameObject.Destroy(sceneItem.itemTransform.gameObject); } m_SceneItems.Clear(); }
public void OnSceneItemRegistered(ISceneItem item) { if (activeStep != null) { activeStep.Add(item); } else { m_SceneItemRegistry.RemoveItemById(item.identifiable.identifier); } }
public void OnEvent(WorkflowStepFinalizedArgs arg) { foreach (SceneItemData data in m_WorkflowService.currentWorkflowData.steps[arg.newDataStep].items) { ISceneItem item = m_ItemRegistry.GetItemById(data.id); if ((item.levelable.level & (1 << m_AdaptivityService.level)) != 0) { item.itemTransform.gameObject.SetActive(true); } } }
/// <inheritdoc /> public void RegisterItem(ISceneItem item) { if (m_SceneItems.ContainsKey(item.identifiable.identifier)) { return; } item.itemTransform.SetParent(m_SceneItemTransform, false); m_SceneItems.Add(item.identifiable.identifier, item); itemAdded.Invoke(item); }
public override ISceneItem GetSceneObjByIndex(int index) { ISceneItem item = null; if (m_mapAllSceneItem.ContainsKey(index)) { item = m_mapAllSceneItem[index]; } return(item); }
public void OnEvent(WorkflowStepEndedArgs arg) { if (arg.lastStep != -1) { foreach (SceneItemData data in m_WorkflowService.currentWorkflowData.steps[arg.lastDataStep].items) { ISceneItem item = m_ItemRegistry.GetItemById(data.id); item.itemTransform.gameObject.SetActive(false); } } }
public void OnEvent(AdaptivityLevelChangedEventArgs arg) { if (!m_WorkflowService.isRunning) { return; } foreach (SceneItemData data in m_WorkflowService.currentWorkflowData.steps[m_WorkflowService.currentDataStep].items) { ISceneItem item = m_ItemRegistry.GetItemById(data.id); item.itemTransform.gameObject.SetActive((item.levelable.level & (1 << m_AdaptivityService.level)) != 0); } }
/// <inheritdoc /> public void RemoveItemById(int id) { if (!m_SceneItems.ContainsKey(id)) { return; } ISceneItem sceneItem = m_SceneItems[id]; sceneItem.itemTransform.SetParent(null); m_SceneItems.Remove(id); itemRemoved.Invoke(sceneItem); GameObject.Destroy(sceneItem.itemTransform.gameObject); }
public CapturePage(SceneEditingModel model, ISceneItem editing, Func <IDevice, CaptureSource[]> sourceGetter, Func <ISceneItem, SceneItemSourceCapture> getConfig, Action <SceneItemSource, SceneItemSourceCapture> setConfig) { _model = model; _sourceGetter = sourceGetter; _getConfig = getConfig; _setConfig = setConfig; _editing = editing; CursorSupported = model.SceneState.Device.ApiContract >= ScreenCaptureManager.CursorSupported; CaptureCursor.OnChange = (o, n) => UpdateCursor(); UpdateFromModel(); }
public SceneItemModel(ISceneItem item, string id, SceneItemModelType type) { Id = id; Type = type; Model = item; Rect = new Property <SceneRect>(item.Rect); Zoom = new ZoomModel(); Rect.OnChange = (o, n) => Model.Rect = n; Zoom.Changed = () => { Model.Ptz = Zoom.GetPtz(); Model.ZoomBehavior = Zoom.ZoomBehavior.Value.Value; }; }
public WebBrowserPageEdit(SceneEditingModel parent, ISceneItem item) { Editing = true; _item = item; var web = item.Source.Web; Url.Value = web.Url; Resolution.Value = Resolutions.FirstOrDefault(s => s.Width == web.Width && s.Height == web.Height) ?? Custom; CustomWidth.Value = web.Width.ToString(); CustomHeight.Value = web.Height.ToString(); Go.Execute = () => { item.Source = GetModel(); Update(); }; }
public void OnObjectDropped(ReorderableList.ReorderableListEventStruct e) { RectTransform droppedTransform = e.DroppedObject.transform as RectTransform; Canvas parentCanvas = (e.DroppedObject.transform as RectTransform).GetParentCanvas(); Camera parentCamera = parentCanvas.worldCamera; Vector2 canvasSize = parentCanvas.pixelRect.size * parentCanvas.scaleFactor; Vector2 pivot = droppedTransform.anchorMin * droppedTransform.anchorMax; Vector2 screenOffset = pivot * canvasSize; Vector3 screenPosition = screenOffset + droppedTransform.anchoredPosition * parentCanvas.scaleFactor; screenPosition.z = 1; Ray ray = new Ray(parentCamera.ScreenToWorldPoint(screenPosition), parentCamera.transform.forward); Plane plane = new Plane(-parentCamera.transform.forward, Vector3.zero); plane.Raycast(ray, out float d); Vector3 worldPos = ray.GetPoint(d); SceneItemElementViewController controller = e.DroppedObject.GetComponent <SceneItemElementViewController>(); if ((e.FromList.transform as RectTransform).rect.Contains(e.DroppedObject.transform.position)) { Destroy(e.DroppedObject); return; } // create scene item SceneItemData data = SceneItemData.Empty; data.position = worldPos; data.payloadType = controller.sceneItemTemplateData.payloadType; data.payload = data.payloadType == PayloadType.Primitive ? controller.sceneItemTemplateData.itemName : controller.payload; ISceneItem item = m_SceneItemFactory.Create(data); e.DroppedObject.transform.parent = null; Destroy(e.DroppedObject); }
public IStepItem Create(WorkflowStepData param, UnityEngine.Object prefab) { IStepItem item = m_Instantiator.InstantiatePrefab(prefab).GetComponent <IStepItem>(); item.identifiable.identifier = Guid.ParseExact(param.id, "N"); item.duration = param.durations[0]; item.repetitions = param.repetitions; item.automatic = param.automatic; item.triggerId = param.triggerId; item.name = param.name; byte levels = 0; foreach (SceneItemData itemData in param.items) { ISceneItem sceneItem = m_ItemFactory.Create(itemData); item.Add(sceneItem); levels |= sceneItem.levelable.level; } return(item); }
public LovensePage(SceneEditingModel model, ISceneItem editedItem) { _model = model; _editedItem = editedItem; RefreshState(); Refresh = () => { PluginContextSetup.TryToLoad(); if (editedItem == null && IsInstalled(_model)) { AddPlugin(model); } else { RefreshState(); } }; Download = () => model.Environment.OpenUrl("https://streamster.io/how-to-install-the-lovense-streamster-toolset"); HowToUseIt = () => model.Environment.OpenUrl("https://streamster.io/how-to-install-the-lovense-streamster-toolset"); }
private void ParseIdAndName(XElement effect, ISceneItem sceneEffect) { var idAttr = effect.Attribute(this.schema.idName); if (idAttr != null) { sceneEffect.Id = idAttr.Value; } var nameAttr = effect.Attribute(this.schema.nameName); sceneEffect.Name = (nameAttr != null) ? nameAttr.Value : sceneEffect.Id; }
private VideoInputConfigBase RebuildInputSource(string id, SceneItemSource source, ISceneItem item, StreamerRebuildContext rebuildContext) { rebuildContext.SetVideoSource(id, source); if (source.Device != null) { return(RebuildInputSource_Device(id, source.Device, item, rebuildContext)); } else if (source.Image != null) { return(RebuildInputSource_Image(id, source.Image, rebuildContext)); } else if (source.Lovense != null) { return(RebuildInputSource_Lovense(id, rebuildContext)); } else if (source.Web != null) { return(RebuildInputSource_Web(id, source.Web, rebuildContext)); } else if (source.CaptureDisplay != null) { return(RebuildInputSource_Capture(id, source.CaptureDisplay, false, rebuildContext)); } else if (source.CaptureWindow != null) { return(RebuildInputSource_Capture(id, source.CaptureWindow, true, rebuildContext)); } else { return(GetFailedInputSource(id, rebuildContext, InputIssueDesc.UnknownTypOfSource, "Video source is unknown")); } }
public abstract void RegisterSceneItem(ISceneItem item);
public DevicePage(SceneEditingModel model, ISceneItem editedItem) { _model = model; _editedItem = editedItem; UpdateCameras(); }
public void AddListener(ISceneItem listener) { listeners.Add(listener); }
public static string GetVideoOptions(LocalVideoSource device, int fps, Resolution resolution, ISceneItem item) { var caps = device.Capabilities; if (caps == null || caps.Length == 0) { Log.Warning($"Video device {device.Name} does not contain capabilities"); return(UnknownOptions); } var optimalResolution = resolution; if (item.ZoomBehavior == ZoomResolutionBehavior.Always) { optimalResolution = new Resolution(3840, 2160); // 4k } else if (item.ZoomBehavior == ZoomResolutionBehavior.DependingOnZoom) { optimalResolution = new Resolution((int)(optimalResolution.Width * item.Rect.W / item.Ptz.W), (int)(optimalResolution.Height * item.Rect.H / item.Ptz.H)); } if (caps.Length == 1) { return(GetVideoOptions(caps[0], fps)); } var ideal = caps.FirstOrDefault(s => s.Fmt == LocalVideoSourceCapabilityFormat.Raw && s.W == optimalResolution.Width && s.H == optimalResolution.Height && s.MinF <= fps && fps <= s.MaxF); if (ideal != null) { return(GetVideoOptions(ideal, fps)); } var max = caps.Select(c => new { cap = c, score = GetScore(c, fps, optimalResolution) }).Aggregate((i1, i2) => i1.score > i2.score ? i1 : i2).cap; return(GetVideoOptions(max, fps)); }
private VideoInputConfigBase RebuildInputSource_Device(string id, SceneItemSourceDevice device, ISceneItem item, StreamerRebuildContext rebuildContext) { var localDevice = _sources.GetLocalVideoDevice(device.DeviceName); if (localDevice != null) { var options = DShowOptionsSelector.GetVideoOptions(localDevice, _coreData.Settings.Fps, _coreData.Settings.Resolution, item); return(new VideoInputConfigFull(new InputSetup( Type: "dshow", Input: $"video={DShowOptionsSelector.GetDeviceName(localDevice)}", Options: options))); } else { return(GetFailedInputSource(id, rebuildContext, InputIssueDesc.VideoRemoved, $"Video device '{device?.DeviceName}' not found")); } }