Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();

        DrawDefaultInspector();

        DataSetLoadBehaviour dslb = (DataSetLoadBehaviour)target;

        // If this instance is a prefab don't show anything in the inspector.
        if (QCARUtilities.GetPrefabType(dslb) == PrefabType.Prefab)
        {
            return;
        }

        // We know that the data set manager also has a default data set that we don't want to use => "num - 1".
        string[] dataSetList = new string[ConfigDataManager.Instance.NumConfigDataObjects - 1];
        // Fill list with available data sets.
        ConfigDataManager.Instance.GetConfigDataNames(dataSetList, false);

        DrawDataSets(dslb, dataSetList);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(dslb);
        }
    }
Exemplo n.º 2
0
    // Draws a drop down list to choose a data set to activate.
    private void DrawDataSetToActivate(DataSetLoadBehaviour dslb, string[] dataSetList)
    {
        string[] dataSetListDropDownList = new string[dataSetList.Length + 1];
        dataSetListDropDownList[0] = "None";
        dataSetList.CopyTo(dataSetListDropDownList, 1);

        int currentDataSetIndex = QCARUtilities.GetIndexFromString(dslb.DataSetToActivate, dataSetListDropDownList);

        if (currentDataSetIndex < 0)
        {
            currentDataSetIndex = 0;
        }

        int newDataSetIndex = EditorGUILayout.Popup("Activate Data Set",
                                                    currentDataSetIndex,
                                                    dataSetListDropDownList);

        if (newDataSetIndex < 1)
        {
            dslb.DataSetToActivate = null;
        }
        else
        {
            dslb.DataSetToActivate = dataSetListDropDownList[newDataSetIndex];
        }
    }
    public static bool RefreshDatasets(DataSetLoadBehaviour dataSetBehaviour)
    {
        if (!QCARRuntimeUtilities.IsQCAREnabled())
        {
            return false;
        }

        if (QCARRuntimeUtilities.IsPlayMode())
        {
            // initialize QCAR
            QCARUnity.CheckInitializationError();
        }

        if (TrackerManager.Instance.GetTracker<ImageTracker>() == null)
        {
            TrackerManager.Instance.InitTracker<ImageTracker>();
        }else{
            ImageTracker imageTracker = (ImageTracker)TrackerManager.Instance.GetTracker<ImageTracker>();
            imageTracker.DestroyAllDataSets(true);
        }

        if (dataSetBehaviour.mDataSetsToLoad.Count <= 0)
        {
            Debug.LogWarning("No data sets defined. Not loading any data sets.");
            return false;
        }

        foreach (string dataSetName in dataSetBehaviour.mDataSetsToLoad)
        {
            if (!DataSet.Exists(dataSetName))
            {
                Debug.LogWarning("Data set " + dataSetName + " does not exist.");
                return false;
            }

            ImageTracker imageTracker = (ImageTracker)TrackerManager.Instance.GetTracker<ImageTracker>();
            DataSet dataSet = imageTracker.CreateDataSet();

            if (!dataSet.Load(dataSetName))
            {
                Debug.LogWarning("Failed to load data set " + dataSetName + ".");
                return false;
            }

            // Activate the data set if it is the one specified in the editor.
            if (dataSetBehaviour.mDataSetsToActivate.Contains(dataSetName))
            {
                imageTracker.ActivateDataSet(dataSet);
            }
        }

        return true;
    }
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go != null )
            {
                dslb = go.GetComponent<DataSetLoadBehaviour>();
            }

            _checkDataSetLoadState();

            if (!everyFrame)
            {
                Finish();
            }
        }
Exemplo n.º 5
0
    // Draws check boxes for all data sets to choose to load them.
    private void DrawDataSets(DataSetLoadBehaviour dslb, string[] dataSetList)
    {
        foreach (string dataSet in dataSetList)
        {
            bool prevLoadDataSet     = dslb.mDataSetsToLoad.Contains(dataSet);
            bool prevActivateDataSet = dslb.mDataSetsToActivate.Contains(dataSet);

            bool nowLoadDataSet     = EditorGUILayout.Toggle("Load Data Set " + dataSet, prevLoadDataSet);
            bool nowActivateDataSet = false;
            if (nowLoadDataSet)
            {
                nowActivateDataSet = EditorGUILayout.Toggle("                     Activate", prevActivateDataSet);
            }

            if (dataSet != dataSetList[dataSetList.Length - 1])
            {
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();
            }

            // LOAD
            // Remove data sets that are being unchecked.
            if (prevLoadDataSet && (!nowLoadDataSet))
            {
                dslb.mDataSetsToLoad.Remove(dataSet);
            }
            // Add data sets that are being checked.
            else if ((!prevLoadDataSet) && nowLoadDataSet)
            {
                dslb.mDataSetsToLoad.Add(dataSet);
            }

            // ACTIVATE
            // Remove data sets that are being unchecked.
            if (prevActivateDataSet && (!nowActivateDataSet))
            {
                dslb.mDataSetsToActivate.Remove(dataSet);
            }
            // Add data sets that are being checked.
            else if ((!prevActivateDataSet) && nowActivateDataSet)
            {
                dslb.mDataSetsToActivate.Add(dataSet);
            }
        }
    }
Exemplo n.º 6
0
    // Draws check boxes for all data sets to choose to load them.
    private void DrawDataSetsToLoad(DataSetLoadBehaviour dslb, string[] dataSetList)
    {
        foreach (string dataSet in dataSetList)
        {
            bool loadDataSet = dslb.mDataSetsToLoad.Contains(dataSet);

            // Remove data sets that are being unchecked.
            if (loadDataSet && (!EditorGUILayout.Toggle("Load Data Set " + dataSet, loadDataSet)))
            {
                dslb.mDataSetsToLoad.Remove(dataSet);
            }
            // Add data sets that are being checked.
            else if ((!loadDataSet) && EditorGUILayout.Toggle("Load Data Set " + dataSet, loadDataSet))
            {
                dslb.mDataSetsToLoad.Add(dataSet);
            }
        }
    }
Exemplo n.º 7
0
    // Draws check boxes for all data sets to choose to load them.
    private void DrawDataSetsToLoad(DataSetLoadBehaviour dslb, string[] dataSetList)
    {
        foreach (string dataSet in dataSetList)
        {
            bool loadDataSet = dslb.mDataSetsToLoad.Contains(dataSet);

            // Remove data sets that are being unchecked.
            if (loadDataSet && (!EditorGUILayout.Toggle("Load Data Set " + dataSet, loadDataSet)))
            {
                dslb.mDataSetsToLoad.Remove(dataSet);
            }
            // Add data sets that are being checked.
            else if ((!loadDataSet) && EditorGUILayout.Toggle("Load Data Set " + dataSet, loadDataSet))
            {
                dslb.mDataSetsToLoad.Add(dataSet);
            }
        }
    }
Exemplo n.º 8
0
    // Draws check boxes for all data sets to choose to load them.
    private void DrawDataSets(DataSetLoadBehaviour dslb, string[] dataSetList)
    {
        foreach (string dataSet in dataSetList)
        {
            bool prevLoadDataSet = dslb.mDataSetsToLoad.Contains(dataSet);
            bool prevActivateDataSet = dslb.mDataSetsToActivate.Contains(dataSet);

            bool nowLoadDataSet = EditorGUILayout.Toggle("Load Data Set " + dataSet, prevLoadDataSet);
            bool nowActivateDataSet = false;
            if (nowLoadDataSet)
                nowActivateDataSet = EditorGUILayout.Toggle("                     Activate", prevActivateDataSet);

            if (dataSet != dataSetList[dataSetList.Length - 1])
            {
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();
            }

            // LOAD
            // Remove data sets that are being unchecked.
            if (prevLoadDataSet && (!nowLoadDataSet))
            {
                dslb.mDataSetsToLoad.Remove(dataSet);
            }
            // Add data sets that are being checked.
            else if ((!prevLoadDataSet) && nowLoadDataSet)
            {
                dslb.mDataSetsToLoad.Add(dataSet);
            }

            // ACTIVATE
            // Remove data sets that are being unchecked.
            if (prevActivateDataSet && (!nowActivateDataSet))
            {
                dslb.mDataSetsToActivate.Remove(dataSet);
            }
            // Add data sets that are being checked.
            else if ((!prevActivateDataSet) && nowActivateDataSet)
            {
                dslb.mDataSetsToActivate.Add(dataSet);
            }
        }
    }
Exemplo n.º 9
0
    // Draws a drop down list to choose a data set to activate.
    private void DrawDataSetToActivate(DataSetLoadBehaviour dslb, string[] dataSetList)
    {
        string[] dataSetListDropDownList = new string[dataSetList.Length + 1];
        dataSetListDropDownList[0] = "None";
        dataSetList.CopyTo(dataSetListDropDownList, 1);

        int currentDataSetIndex = QCARUtilities.GetIndexFromString(dslb.DataSetToActivate, dataSetListDropDownList);
        if (currentDataSetIndex < 0)
            currentDataSetIndex = 0;

        int newDataSetIndex = EditorGUILayout.Popup("Activate Data Set",
                                                    currentDataSetIndex,
                                                    dataSetListDropDownList);
        if (newDataSetIndex < 1)
            dslb.DataSetToActivate = null;
        else
        {
            dslb.DataSetToActivate = dataSetListDropDownList[newDataSetIndex];
        }
    }