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 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 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 void DuplicateTarget() { SceneItemData data = m_DataFactory.Create(m_ParentHandle.target); m_ItemFactory.Create(data); }