示例#1
0
        void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
        {
            LoaderInfo info  = m_LoadersInUse[index];
            var        label = (info.instance == null) ? EditorGUIUtility.TrTextContent("Missing (XRLoader)") : EditorGUIUtility.TrTextContent(info.assetName);

            EditorGUI.LabelField(rect, label);
        }
示例#2
0
        void AddLoaderMenuSelected(object data)
        {
            int        selected = (int)data;
            LoaderInfo info     = m_LoadersNotInUse[selected];

            AddLoaderMenu(info);
        }
示例#3
0
        internal static void GetAllKnownLoaderInfos(List <LoaderInfo> newInfos)
        {
            var loaderTypes = TypeLoaderExtensions.GetAllTypesWithInterface <XRLoader>();

            foreach (Type loaderType in loaderTypes)
            {
                // HACK: No need for people to see these loaders
                if (String.Compare("DummyLoader", loaderType.Name, StringComparison.OrdinalIgnoreCase) == 0 ||
                    String.Compare("SampleLoader", loaderType.Name, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    continue;
                }

                var assets = AssetDatabase.FindAssets(String.Format("t:{0}", loaderType));
                if (!assets.Any())
                {
                    LoaderInfo info = new LoaderInfo();
                    info.loaderType = loaderType;
                    newInfos.Add(info);
                }
                else
                {
                    foreach (var asset in assets)
                    {
                        string path = AssetDatabase.GUIDToAssetPath(asset);

                        LoaderInfo info = new LoaderInfo();
                        info.loaderType = loaderType;
                        info.instance   = AssetDatabase.LoadAssetAtPath(path, loaderType) as XRLoader;
                        info.assetName  = Path.GetFileNameWithoutExtension(path);
                        newInfos.Add(info);
                    }
                }
            }
        }
示例#4
0
        void AddLoaderMenuSelected(object data)
        {
            int        selected = (int)data;
            LoaderInfo info     = m_LoadersNotInUse[selected];

            if (info.instance == null)
            {
                string   newAssetName = String.Format("New {0}.asset", TypeNameToString(info.loaderType));
                XRLoader loader       = ScriptableObject.CreateInstance(info.loaderType) as XRLoader;
                string   assetPath    = EditorUtility.SaveFilePanelInProject("Create new XR Loader asset",
                                                                             newAssetName,
                                                                             "asset",
                                                                             "Please enter a name and location where the loader asset can be created at.");

                if (string.IsNullOrEmpty(assetPath))
                {
                    return;
                }

                info.instance  = loader;
                info.assetName = Path.GetFileNameWithoutExtension(assetPath);
                AssetDatabase.CreateAsset(loader, assetPath);
                m_ShouldReload = true;
            }

            m_LoadersNotInUse.Remove(info);
            info.isUsed = true;
            m_LoadersInUse.Add(info);
            UpdateSerializedProperty();
        }
示例#5
0
        void RemoveInstanceFromList(ReorderableList list)
        {
            LoaderInfo info = m_LoadersInUse[list.index];

            RemoveInfo(info);
            UpdateSerializedProperty();
        }
示例#6
0
        void RemoveInstanceFromList(ReorderableList list)
        {
            LoaderInfo info = m_LoadersInUse[list.index];

            m_LoadersInUse.Remove(info);

            if (info.loaderType != null)
            {
                info.isUsed = false;
                m_LoadersNotInUse.Add(info);
            }
            UpdateSerializedProperty();
        }
示例#7
0
        void RemoveInstanceFromList(ReorderableList list)
        {
            LoaderInfo info = m_LoadersInUse[list.index];

            m_LoadersInUse.Remove(info);

            if (info.loaderType != null)
            {
                m_LoadersInUse.Remove(info);

                m_ShouldReload = true;
            }
            UpdateSerializedProperty();
        }
示例#8
0
        void PopulateLoaderInfosFromCurrentAssignedLoaders()
        {
            for (int i = 0; i < m_LoaderList.arraySize; i++)
            {
                var prop = m_LoaderList.GetArrayElementAtIndex(i);

                LoaderInfo info = new LoaderInfo();
                info.loaderType = (prop.objectReferenceValue == null) ? null : prop.objectReferenceValue.GetType();
                info.assetName  = AssetNameFromInstance(prop.objectReferenceValue);
                info.instance   = prop.objectReferenceValue as XRLoader;
                info.isUsed     = true;
                m_AllLoaderInfos.Add(info);
            }
        }
示例#9
0
        void AddLoaderMenu(LoaderInfo info)
        {
            if (info.instance == null)
            {
                string   newAssetName = String.Format("{0}.asset", EditorUtilities.TypeNameToString(info.loaderType));
                XRLoader loader       = ScriptableObject.CreateInstance(info.loaderType) as XRLoader;
                string   assetPath    = EditorUtilities.GetAssetPathForComponents(EditorUtilities.s_DefaultLoaderPath);
                if (string.IsNullOrEmpty(assetPath))
                {
                    return;
                }

                assetPath      = Path.Combine(assetPath, newAssetName);
                info.instance  = loader;
                info.assetName = Path.GetFileNameWithoutExtension(assetPath);
                AssetDatabase.CreateAsset(loader, assetPath);
                m_ShouldReload = true;
            }

            m_LoadersNotInUse.Remove(info);
            m_LoadersInUse.Add(info);
            UpdateSerializedProperty();
        }
示例#10
0
 void RemoveInfo(LoaderInfo info)
 {
     m_LoadersInUse.Remove(info);
     m_ShouldReload = true;
 }