Beispiel #1
0
        public void LoadWorkflow(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            ClearItems();

            // remove listeners here to prevent deletion of loaded items
            m_SceneItemRegistry.itemAdded.RemoveListener(OnSceneItemRegistered);
            m_SceneItemRegistry.itemRemoved.RemoveListener(OnSceneItemRemoved);

            string       stringData = File.ReadAllText(filePath);
            WorkflowData data       = JsonUtility.FromJson <WorkflowData>(stringData);

            foreach (WorkflowStepData stepData in data.steps)
            {
                IStepItem item = m_StepFactory.Create(stepData, m_StepItemPrefab);
                m_StepItems.Add(item);
                foreach (ISceneItem sceneItem in item.sceneItems)
                {
                    sceneItem.itemTransform.gameObject.SetActive(false);
                }
            }

            // add listeners again
            m_SceneItemRegistry.itemAdded.AddListener(OnSceneItemRegistered);
            m_SceneItemRegistry.itemRemoved.AddListener(OnSceneItemRemoved);

            m_CurrentWorkflow = Path.GetFileNameWithoutExtension(filePath);

            stepsChanged.Invoke(m_StepItems);
            workflowLoaded.Invoke();
        }
Beispiel #2
0
        public void AddStep(WorkflowStepData data)
        {
            IStepItem stepItem = m_StepFactory.Create(data, m_StepItemPrefab);

            m_StepItems.Add(stepItem);
            stepsChanged?.Invoke(m_StepItems);
        }
Beispiel #3
0
        public void ClearItems()
        {
            activeStep = null;
            while (m_StepItems.Count > 0)
            {
                IStepItem item = m_StepItems[0];
                m_StepItems.RemoveAt(0);
                item.Dispose();
            }

            stepsChanged.Invoke(m_StepItems);
        }
Beispiel #4
0
        public void MoveStepFromTo(int sourceIndex, int targetIndex)
        {
            if (sourceIndex == targetIndex ||
                sourceIndex == -1 ||
                sourceIndex >= m_StepItems.Count ||
                targetIndex == -1 ||
                targetIndex >= m_StepItems.Count)
            {
                return;
            }
            IStepItem item = m_StepItems[sourceIndex];

            m_StepItems.RemoveAt(sourceIndex);
            m_StepItems.Insert(targetIndex, item);
            stepsChanged.Invoke(m_StepItems);
        }
Beispiel #5
0
        public void RemoveStepAt(int index)
        {
            if (index == -1 || index >= m_StepItems.Count)
            {
                return;
            }
            IStepItem item = m_StepItems[index];

            if (item == activeStep)
            {
                activeStep = null;
            }
            m_StepItems.RemoveAt(index);
            item.Dispose();
            stepsChanged.Invoke(m_StepItems);
        }
Beispiel #6
0
 public void Inititalize(WorkflowEditorPanel parentPanel, IStepItem item)
 {
     m_Format               = new CultureInfo("en");
     m_ParentPanel          = parentPanel;
     m_DataItem             = item;
     m_StepLabel.text       = m_DataItem.name;
     m_StepDurationMin.text = m_DataItem.duration.x.ToString(m_Format);
     m_StepDurationRed.text = m_DataItem.duration.y.ToString(m_Format);
     m_StepDurationMax.text = m_DataItem.duration.z.ToString(m_Format);
     m_UnifiedDurationsToggle.SetIsOnWithoutNotify(m_DataItem.duration.x == m_DataItem.duration.y &&
                                                   m_DataItem.duration.y == m_DataItem.duration.z);
     m_StepRepetitions.text = m_DataItem.repetitions.ToString(m_Format);
     m_AutomaticToggle.isOn = m_DataItem.automatic;
     m_CameraTriggerId.text = m_DataItem.triggerId.ToString(m_Format);
     m_CameraToggle.isOn    = m_DataItem.triggerId != -1;
 }
Beispiel #7
0
        public void SetActiveStep(int index)
        {
            if (activeStep != null)
            {
                foreach (ISceneItem sceneItem in activeStep.sceneItems)
                {
                    sceneItem.itemTransform.gameObject.SetActive(false);
                }
            }

            IStepItem item = m_StepItems[index];

            activeStep = item;

            foreach (ISceneItem sceneItem in activeStep.sceneItems)
            {
                sceneItem.itemTransform.gameObject.SetActive(true);
            }

            activeStepChanged.Invoke(index);
        }