Exemple #1
0
        public void OnPreprocessBuild(BuildTarget target, string path)
        {
            TriLibSettings.UpdateBatchSettings();
            var pluginsBasePath = TriLibProjectUtils.FindPathRelativeToProject("Plugins");
            var buildTarget     = target;
#endif
            if (buildTarget == BuildTarget.iOS)
            {
#if TRILIB_USE_IOS_SIMULATOR
                var pluginsSuffix = ".debug.a";
#else
                var pluginsSuffix = "release.a";
#endif
#if TRILIB_ENABLE_IOS_FILE_SHARING
                IOSFileSharingEnabled = true;
#else
                IOSFileSharingEnabled = false;
#endif
                var iOSImporters = PluginImporter.GetImporters(BuildTarget.iOS);
                foreach (var importer in iOSImporters)
                {
                    if (importer.isNativePlugin)
                    {
                        if (importer.assetPath.StartsWith(string.Format((string)"{0}/iOS/", (object)pluginsBasePath)))
                        {
                            importer.SetIncludeInBuildDelegate(assetPath => importer.assetPath.EndsWith(pluginsSuffix));
                        }
                    }
                }
                if (!UnityEditorInternal.InternalEditorUtility.inBatchMode)
                {
#if UNITY_EDITOR_OSX
                    EditorUtility.DisplayDialog("TriLib", "Warning: Bitcode is not supported by TriLib and will be disabled.", "Ok");
#else
                    EditorUtility.DisplayDialog("TriLib", "Warning:\nBitcode is not supported. You should disable it on your project settings.", "Ok");
#endif
                }
            }
            var allImporters = PluginImporter.GetImporters(buildTarget);
            foreach (var importer in allImporters)
            {
                if (!importer.isNativePlugin)
                {
                    if (importer.assetPath == string.Format((string)"{0}/ICSharpCode.SharpZipLib.dll", (object)pluginsBasePath))
                    {
#if TRILIB_USE_ZIP
                        importer.SetIncludeInBuildDelegate(assetPath => PlayerSettings.GetScriptingBackend(BuildPipeline.GetBuildTargetGroup(buildTarget)) != ScriptingImplementation.WinRTDotNET);
#else
                        importer.SetIncludeInBuildDelegate(assetPath => false);
#endif
                    }
                }
            }
        }
Exemple #2
0
        public void OnPreprocessBuild(BuildTarget target, string path)
        {
            var pluginsBasePath = TriLibProjectUtils.FindPathRelativeToProject("Plugins");
            var buildTarget     = target;
#endif
            if (buildTarget == BuildTarget.iOS)
            {
                var pluginsLabel = UnityEditorInternal.InternalEditorUtility.inBatchMode || EditorUtility.DisplayDialog("TriLib", "Building to iOS Device (iPhone, iPad) or iOS Simulator?", "release", "debug") ? "_TriLib_iOS_Device_" : "_TriLib_iOS_Simulator_";
#if UNITY_EDITOR_OSX
                _iosFileSharingEnabled = UnityEditorInternal.InternalEditorUtility.inBatchMode || EditorUtility.DisplayDialog("TriLib", "Enable iOS File Sharing?", "Yes", "No");
#endif
                var iOSImporters = PluginImporter.GetImporters(BuildTarget.iOS);
                foreach (var importer in iOSImporters)
                {
                    if (importer.isNativePlugin)
                    {
                        if (importer.assetPath.StartsWith(string.Format((string)"{0}/iOS/", (object)pluginsBasePath)))
                        {
                            importer.SetIncludeInBuildDelegate(assetPath => importer.assetPath.EndsWith(pluginsLabel));
                        }
                    }
                }

                if (!UnityEditorInternal.InternalEditorUtility.inBatchMode)
                {
#if UNITY_EDITOR_OSX
                    EditorUtility.DisplayDialog("TriLib", "Warning: Bitcode is not supported by TriLib and will be disabled.", "Ok");
#else
                    EditorUtility.DisplayDialog("TriLib", "Warning:\nBitcode is not supported. You should disable it on your project settings.\nZLIB library should be included in your project frameworks.", "Ok");
#endif
                }
            }
            var allImporters = PluginImporter.GetImporters(buildTarget);
            foreach (var importer in allImporters)
            {
                if (!importer.isNativePlugin)
                {
                    if (importer.assetPath == string.Format((string)"{0}/ICSharpCode.SharpZipLib.dll", (object)pluginsBasePath))
                    {
#if TRILIB_USE_ZIP
                        importer.SetIncludeInBuildDelegate(assetPath => PlayerSettings.GetScriptingBackend(BuildPipeline.GetBuildTargetGroup(buildTarget)) != ScriptingImplementation.WinRTDotNET);
#else
                        importer.SetIncludeInBuildDelegate(assetPath => false);
#endif
                    }
                }
            }
        }
        /// <summary>
        /// Setups the Avatar Loader instance reference and fills the available files list.
        /// </summary>
        protected void Start()
        {
            _avatarLoader = FindObjectOfType <AvatarLoader>();
            if (_avatarLoader == null)
            {
                Debug.LogError("Could not find any Avatar Loader script instance.");
                return;
            }
#if UNITY_EDITOR
            var modelsPath = string.Format("{0}/Samples/{1}", TriLibProjectUtils.FindPathRelativeToProject("TriLibExtras", "t:DefaultAsset TriLibExtras"), ModelsDirectory);
#else
            var modelsPath = Path.Combine(Path.GetFullPath("."), ModelsDirectory);
#endif
            var supportedExtensions = AssetLoaderBase.GetSupportedFileExtensions();
            _files               = Directory.GetFiles(modelsPath, "*.*").Where(x => supportedExtensions.Contains("*" + FileUtils.GetFileExtension(x) + ";")).ToArray();
            _windowRect          = new Rect(20, 20, 240, Screen.height - 40);
            InformationText.text = string.Format(InformationText.text, ModelsDirectory, modelsPath);
        }
Exemple #4
0
 /// <summary>
 /// Tries to load "Bouncing.fbx" model
 /// </summary>
 protected void Start()
 {
     using (var assetLoader = new AssetLoaderAsync())
     {
         try
         {
             var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
             //assetLoaderOptions.RotationAngles = new Vector3(90f, 180f, 0f);
             assetLoaderOptions.AutoPlayAnimations = true;
             //assetLoaderOptions.UseOriginalPositionRotationAndScale = true;
             assetLoader.LoadFromFile(string.Format("{0}/Bouncing.fbx", TriLibProjectUtils.FindPathRelativeToProject("Models", "t:Model Bouncing")), assetLoaderOptions, null, delegate(GameObject loadedGameObject)
             {
                 //       loadedGameObject.transform.position = new Vector3(128f, 0f, 0f);
             });
         }
         catch (Exception e)
         {
             Debug.LogError(e.ToString());
         }
     }
 }
        public static void ConfigurePlugins()
        {
            var pluginsBasePath = TriLibProjectUtils.FindPathRelativeToProject("Plugins");
            var pluginImporters = PluginImporter.GetAllImporters();

            foreach (var pluginImporter in pluginImporters)
            {
                var    buildTargets     = new List <BuildTarget>();
                var    addToEditor      = true;
                var    addToAnyPlatform = false;
                string editorCPU        = null;
                string targetCPU        = null;
                string targetOS         = null;
                var    assetDirectory   = FileUtils.GetFileDirectory(pluginImporter.assetPath);
                if (assetDirectory.StartsWith(string.Format("{0}/Android", pluginsBasePath), StringComparison.InvariantCultureIgnoreCase))
                {
                    if (assetDirectory.EndsWith("/x86"))
                    {
                        targetCPU = "x86";
                        buildTargets.Add(BuildTarget.Android);
                    }
                    else if (assetDirectory.EndsWith("/armeabi-v7a"))
                    {
                        targetCPU = "ARMV7";
                        buildTargets.Add(BuildTarget.Android);
                    }
                    else if (assetDirectory.EndsWith("/arm64"))
                    {
#if UNITY_2018_1_OR_NEWER
                        targetCPU = "ARM64";
                        buildTargets.Add(BuildTarget.Lumin);
                        buildTargets.Add(BuildTarget.Android);
#endif
                    }
                    addToEditor = false;
                }
                else if (assetDirectory.StartsWith(string.Format("{0}/iOS", pluginsBasePath), StringComparison.InvariantCultureIgnoreCase))
                {
                    targetCPU = "AnyCPU";
                    buildTargets.Add(BuildTarget.iOS);
                    addToEditor = false;
                }
                else if (assetDirectory.StartsWith(string.Format("{0}/UWP", pluginsBasePath), StringComparison.InvariantCultureIgnoreCase))
                {
                    if (assetDirectory.EndsWith("/x86"))
                    {
                        targetCPU = "X86";
                        buildTargets.Add(BuildTarget.WSAPlayer);
                    }
                    else if (assetDirectory.EndsWith("/x86_64"))
                    {
                        targetCPU = "X64";
                        buildTargets.Add(BuildTarget.WSAPlayer);
                    }
                    else if (assetDirectory.EndsWith("/arm64"))
                    {
#if UNITY_2018_1_OR_NEWER
                        targetCPU = "ARM64";
                        buildTargets.Add(BuildTarget.WSAPlayer);
#endif
                    }
                    addToEditor = false;
                }
                else if (assetDirectory.StartsWith(string.Format("{0}/WebGL", pluginsBasePath), StringComparison.InvariantCultureIgnoreCase))
                {
                    targetCPU = "AnyCPU";
                    buildTargets.Add(BuildTarget.WebGL);
                    addToEditor = false;
                }
                else if (assetDirectory.StartsWith(string.Format("{0}/Windows", pluginsBasePath), StringComparison.InvariantCultureIgnoreCase))
                {
                    if (assetDirectory.EndsWith("/x86"))
                    {
                        buildTargets.Add(BuildTarget.StandaloneWindows);
                        editorCPU = "x86";
                        targetCPU = "AnyCPU";
                    }
                    else if (assetDirectory.EndsWith("/x86_64"))
                    {
                        buildTargets.Add(BuildTarget.StandaloneWindows64);
                        editorCPU = "x86_64";
                        targetCPU = "AnyCPU";
                    }
                    targetOS = "Windows";
                }
                else if (assetDirectory.StartsWith(string.Format("{0}/Linux", pluginsBasePath), StringComparison.InvariantCultureIgnoreCase))
                {
                    if (assetDirectory.EndsWith("/x86"))
                    {
                        editorCPU = "x86";
                        targetCPU = "x86";
                        buildTargets.Add(BuildTarget.StandaloneLinux);
                    }
                    else if (assetDirectory.EndsWith("/x86_64"))
                    {
                        editorCPU = "x86_64";
                        targetCPU = "x86_64";
                        buildTargets.Add(BuildTarget.StandaloneLinux64);
                    }
                    targetOS = "Linux";
                }
                else if (assetDirectory.StartsWith(string.Format("{0}/OSX", pluginsBasePath), StringComparison.InvariantCultureIgnoreCase))
                {
                    editorCPU = "AnyCPU";
                    targetCPU = "AnyCPU";
                    buildTargets.Add(BuildTarget.StandaloneOSX);
                    targetOS = "OSX";
                }
                else if (assetDirectory.Equals(pluginsBasePath, StringComparison.InvariantCultureIgnoreCase))
                {
                    targetCPU = "AnyCPU";
                    targetOS  = "AnyOS";
                    AddAllBuildTargets(buildTargets);
                    addToAnyPlatform = true;
                }
                else
                {
                    continue;
                }
                pluginImporter.ClearSettings();
                if (targetCPU == null)
                {
                    RemoveFromAllPlatforms(pluginImporter, buildTargets);
                    Debug.LogWarningFormat("TriLib: Could not find suitable CPU for Plugin '{0}'", pluginImporter.assetPath);
                    continue;
                }
                AddToAnyPlatform(pluginImporter, addToAnyPlatform);
                AddToStandaloneAndEditorPlatforms(pluginImporter, buildTargets, addToEditor);
                SetTargetCPU(pluginImporter, buildTargets, editorCPU, targetCPU, targetOS, addToEditor);
                pluginImporter.SaveAndReimport();
            }
            AssetDatabase.SaveAssets();
        }
Exemple #6
0
 public void OnPreprocessBuild(BuildReport report)
 {
     var pluginsBasePath = TriLibProjectUtils.FindPathRelativeToProject("Plugins");
     var buildTarget     = report.summary.platform;
Exemple #7
0
 //Generates the progress bar textures and starts to load the asset
 private void Start()
 {
     //Generates progress bar textures
     GenerateProgressBarTextures();
     //Creates our AssetLoaderAsync instance
     using (var assetLoaderAsync = new AssetLoaderAsync())
     {
         try
         {
             //Loads the given asset and set the loading progress and loading completed callback
             assetLoaderAsync.LoadFromFile(string.Format("{0}/BigModel.obj", TriLibProjectUtils.FindPathRelativeToProject("Models", "t:Model BigModel")), null, gameObject, OnAssetLoaded, null, OnAssetLoadingProgress);
         }
         catch (Exception e)
         {
             //Stores the error message to show on GUI
             _error = e.ToString();
         }
     }
 }