Exemplo n.º 1
0
        private void LoadProject()
        {
            var path = EditorUtility.OpenFilePanel("Load File", Application.dataPath, $"{UTinyPersistence.ProjectFileImporterExtension},{UTinyPersistence.ModuleFileImporterExtension}");

            if (!string.IsNullOrEmpty(path))
            {
                if (!UTinyEditorApplication.SaveChanges())
                {
                    return;
                }

                // Convert to relative path
                if (path.StartsWith(Application.dataPath))
                {
                    path = "Assets" + path.Substring(Application.dataPath.Length);
                }

                m_TabType = TabType.Settings;
                UTinyEditorApplication.Close();

                var extension = Path.GetExtension(path);
                switch (extension)
                {
                case UTinyPersistence.ProjectFileExtension:
                    UTinyEditorApplication.LoadProject(path);
                    break;

                case UTinyPersistence.ModuleFileExtension:
                    UTinyEditorApplication.LoadModule(path);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public static bool OnOpenAsset(int instanceId, int line)
        {
            //HACK: using the selection instead of the instance ID since this hook is not reliable
            var obj = Selection.activeObject;

            if (obj is UTProject)
            {
                var window = UTinyProjectWindow.OpenAndShow();
                window.SetTabType(UTinyProjectWindow.TabType.Settings);
                UTinyEditorApplication.LoadProject(AssetDatabase.GetAssetPath(obj));
                return(true);
            }
            return(false);
        }