I have an app that should open certain file types. From the app itself, it's quite straightforward with file_picker plugin. But how to open a file trough the file manager? In other words, trough the "Open with" context menu.
I tried checking the arguments passed to main, but they are always empty. Registering a universal link wouldn't make much sense either since I only need to pass the file - nothing more.
The Mac problem is related to the fact that the development sandboxes your program. I encountered a similar problem and tried to summarize it on
Entitlement issue
you can find the setting in the entitlements (debug and release) at
<key>com.apple.security.app-sandbox</key><true/>
if (await canLaunch("file://..path...xlsx")) {
await launch("file://..path...xlsx");
} else {
print("cannot launch url ]:");
}
this simple snippet basically works both on windows and mac os! If you can deal with path with classic path_provider, you'd be able to use the same feature on web, ios, android also. In my test, web downloaded the file when i typed and entered the file:// url.
So, i guess the uri scheme is the one who does these tricks. I tried a few types of files and as i commented, excel works just fine and the finder(or file explorer) also work. In my test, pptx even worked with the file url. Yes, it opens the native app. I couldn't have found out "open with.." option, but it meant that it automatically open xlsx file in excel(ie. ATM i don't have any option to launch "open with.." pop-up tho).
Similarly, i could have even found that instagram:// also works with url launcher. One thing unexpectedly tough was to set a proper path on mac os desktop. Since the app is being debugged somewhere assigned previously by Mr. Apple, simply calling methods from path_provider returned a path far away from desktop path, the home screen, since the app is running on somewhere else(like /Users/${MacOsUser}/Library/Containers/${fullPackagePath}/Data/Documents for mac os, which would be different in the distribution stage).
Hope this would help. FYI, i couldn't launch battle.net and league of legends with this method, which don't show their extensions in the file explorer ]: Have a wonderful day [:
Related
I have made a Unity build and would like to share it with colleagues.
But i dont want to share it as the standard "folder structure" -build.
So, I have made a single .exe file with an icon, using Winrar selfextracting file.
It works great....BUT Windows and antivirus apps screams bloody murder when they try and open it, thinking it is a potential virus of course.
That makes the file unusable for web sharing (Sharing on a USB drive there are no problems).
How can I make a single file build, for web download, that does not make Windows and Antivirus apps go crazy?
Basically...
You need to pack(age) the build of the app.
(Note the boxing app in the linked tutorial is just an example. There are many ways to pack the game into an executable, and you don't need that specific one.)
Depending on platform, it's also either required or recommended that you sign (1)(2) the app and/or executable.
That's not that trivial since antivirus hate selfextracting exe files ;)
Either go with the usual folder structure and ship it as a .zip.
Or you could go the correct but more complex way and create a proper Installer that correctly asks for admin permissions and then is allowed to extract content into the usual program paths.
Or you can try and use this but it might underly the same issue as the selfextracting exe.
I found a terrific reference on how to get started with file pickers. But with that being said, I am not able to get the provided code working for my Unity Hololens app.
My scenario:
I've a file, lets say an object file, like such, 3DModel.obj. I want my app to be able to locate this file (3DModel.obj) at runtime, and then load it at runtime.
I'm attempting to use these read/write functions but I'm getting no where. I've run through numerous functions such as, Windows.Storage.ApplicationData.Current.RoamingFolder, KnownFolder, LocalFolder, dataPath, persistentDataPath.
I've perused through Microsofts file picker documentation, and I'm still left scratching my head.
None of these seem to accomplish what I'm trying to do, or my ineptitude and lack of knowledge on how to use file pickers fails to get the job done.
Limitations of the HoloLens shell:
File Explorer and Local File System
The Windows Holographic app model does not currently expose the concept of a file system. There are known folders, but there is no built in, local File Explorer app like on Windows Desktop or Mobile. Apps can save files to their local state folders. Apps can also save files to a registered File Picker app like OneDrive.
Upon quitting my application, I use PlayerPrefs.Save() to save the player preferences.
I understand this function writes all the modified preferences to disk.
So, I clicked on Start, typed regedit and opened it, went into HKEY_CURRENT_USER and then Software and then I selected Unity.
So, now I can see the file (is this actually a file?) but I cannot figure out how to open it or see the contents...
Neither double-clicking on it works nor right-clicking on it brings up any menu with options.
How do I access the contents, or perhaps clear/flush it after a while?
You find the PlayerPrefs under:
HKEY_CURRENT_USER/SOFTWARE/[NAME OF THE COMPANY YOU SPECIFIED IN PLAYESETTINGS]/[PRODUCTNAME YOU SPECIFIED IN PLAYERSETTINGS]
If you had checked unity's documentation it is very well explained for each platform here
The exact storage of PlayerPrefs depends on the platform. For Windows it is stored in the registry, as you have seen.
This is not an isolated file for your Unity game. As such, there is nothing really to open. You could edit the registry if you wanted to, but that's not really the appropriate way. Just keep using it via the provided PlayerPrefs API.
If you want to clear your playerprefs, you can call PlayerPrefs.DeleteAll(). This will clear all playerprefs data and would allow you to "simulate" a new user starting from scratch for example.
For Win32 and Win64 builds it is in a Registry file editable from the registry.
In OS X builds it is in a plist file in ~/Library/Preferences These are in plist compliant format and can be edited in the standard OS X plist editor, or a text editor if you follow proper syntax.
In Windows Store builds it is in %userprofile%\AppData\Local\Packages[ProductPackageId]>\LocalState\playerprefs.dat (I don't know the format of this.)
Windows Phone builds store it in the application's local folder, again no documentation on format.
Android and Linux are in xml format, editable with a standard text editor.
The Android config files are package's shared prefs directory and the Linux config files are under ~/.config/.unity3d
I have application to rebuild in Eclipse which has an option to choose a language. It has a res folder with few .res files(one file for each language, like so English.res, Spanish.res) that are used by the app. When opened in Notepad I can read almost all of it (it contains strings that are fetched by the app during run process based on the app's active language) but as soon as I try to edit the string and run the app, it throws NullPointerException... Does anyone know or faced this type of files or maybe knows how to open them for editing, what program to use? When I google it it says the best option is to use Visual Studio but the file cannot be recognized by VS...
Everything in that file is written in one line with funny combination of signs for "new line" like: square or two squares + "Z".
Please any help or advice?
Thanks
I have a text based file i have given an extension named .val i have also changed its icon by selecting Computer>Open tools>Open folder options>
however though this changes the icon for the extension it only changes it on my computer, I would like to know how I can do this for all machines. even if that means building somthing that needs to be installed, which is fine with me
I wrote a little program awhile ago. The windows registry thing is a mess. Save yourself a lot of time and use this installer package - it has a wizard that will create an install script for you. Navigate to your program, icon, etc. Pretty easy.
http://hmne.sourceforge.net/
As I recall, in windows icons are set based on what program is opening it, so indirectly the file type. So first you have to create reg entries for your application on your computer. Then you have to associate that file type with your extension. And then the extension gets the icon from your app settings. This of course is different in WinXP vs. Win7. Thus why I think you should avoid a lot of headache and use an installer.
[HKEY_CLASSES_ROOT\Your App\DefaultIcon]