inkle / ink-unity-integration

Unity integration for the open source ink narrative scripting language.
http://www.inklestudios.com/ink
Other
581 stars 101 forks source link

Unity package manager package (#84) #122

Closed rhys-vdw closed 4 years ago

rhys-vdw commented 4 years ago

Okay, this is my start on the UPM package. The idea is that we can add this subdirectory to OpenUPM.

It's still WIP (I want to do some more testing) but added here if anyone wants to take a look.

Closes #84

Pls merge #124 before this one.

TODO

rhys-vdw commented 4 years ago

Okay, I'm getting the following errors when adding this to another project:

DirectoryNotFoundException: Could not find a part of the path "/Users/rhysvanderwaerden/Projects/gmtk2019/GMTK2019/Assets/s/com.inklestudios.ink-unity-integration/Example/Ink/story.ink".
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <fb001e01371b4adca20013e0ac763896>:0)
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) (at <fb001e01371b4adca20013e0ac763896>:0)
(wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) (at <fb001e01371b4adca20013e0ac763896>:0)
System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) (at <fb001e01371b4adca20013e0ac763896>:0)
System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) (at <fb001e01371b4adca20013e0ac763896>:0)
System.IO.StreamReader..ctor (System.String path) (at <fb001e01371b4adca20013e0ac763896>:0)
(wrapper remoting-invoke-with-check) System.IO.StreamReader..ctor(string)
System.IO.File.ReadAllText (System.String path) (at <fb001e01371b4adca20013e0ac763896>:0)
Ink.UnityIntegration.InkMetaFile.GetFileContents () (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaFile.cs:196)
Ink.UnityIntegration.InkMetaFile.ParseContent () (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaFile.cs:200)
Ink.UnityIntegration.InkMetaFile..ctor (Ink.UnityIntegration.InkFile inkFile) (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaFile.cs:110)
Ink.UnityIntegration.InkMetaLibrary.GetInkMetaFile (Ink.UnityIntegration.InkFile inkFile) (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaLibrary.cs:120)
Ink.UnityIntegration.InkMetaLibrary.get_Instance () (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaLibrary.cs:25)
Ink.UnityIntegration.InkMetaLibrary.GetInkMetaFile (Ink.UnityIntegration.InkFile inkFile) (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaLibrary.cs:114)
Ink.UnityIntegration.InkFile.get_metaInfo () (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkFile.cs:26)
Ink.UnityIntegration.InkLibrary.RequiresRebuild () (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:114)
Ink.UnityIntegration.InkLibrary.Validate () (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:91)
Ink.UnityIntegration.InkLibrary.set_Instance (Ink.UnityIntegration.InkLibrary value) (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:39)
Ink.UnityIntegration.InkLibrary.OnEnable () (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:73)
UnityEditor.AssetDatabase:LoadAssetAtPath(String)
Ink.UnityIntegration.InkEditorUtils:FindAndEnforceSingletonScriptableObjectOfType() (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/InkEditorUtils.cs:301)
Ink.UnityIntegration.InkEditorUtils:FastFindAndEnforceSingletonScriptableObjectOfType() (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/InkEditorUtils.cs:289)
Ink.UnityIntegration.InkEditorUtils:FindOrCreateSingletonScriptableObjectOfType(String, InkLibrary&) (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/InkEditorUtils.cs:272)
Ink.UnityIntegration.InkLibrary:get_Instance() (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:28)
Ink.UnityIntegration.InkLibrary:Clean() (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:140)
Ink.UnityIntegration.InkLibrary:Rebuild() (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:168)
Ink.UnityIntegration.InkEditorUtils:OnOpenUnityEditor() (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/InkEditorUtils.cs:59)
Ink.UnityIntegration.InkEditorUtils:.cctor() (at /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/InkEditorUtils.cs:47)
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes(Type[]) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:114)
System.IO.DirectoryNotFoundException: Could not find a part of the path "/Users/rhysvanderwaerden/Projects/gmtk2019/GMTK2019/Assets/s/com.inklestudios.ink-unity-integration/Example/Ink/story.ink".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00164] in <fb001e01371b4adca20013e0ac763896>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <fb001e01371b4adca20013e0ac763896>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) [0x00067] in <fb001e01371b4adca20013e0ac763896>:0 
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00000] in <fb001e01371b4adca20013e0ac763896>:0 
  at System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) [0x0000d] in <fb001e01371b4adca20013e0ac763896>:0 
  at System.IO.StreamReader..ctor (System.String path) [0x00000] in <fb001e01371b4adca20013e0ac763896>:0 
  at (wrapper remoting-invoke-with-check) System.IO.StreamReader..ctor(string)
  at System.IO.File.ReadAllText (System.String path) [0x00000] in <fb001e01371b4adca20013e0ac763896>:0 
  at Ink.UnityIntegration.InkMetaFile.GetFileContents () [0x0004b] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaFile.cs:196 
  at Ink.UnityIntegration.InkMetaFile.ParseContent () [0x00001] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaFile.cs:200 
  at Ink.UnityIntegration.InkMetaFile..ctor (Ink.UnityIntegration.InkFile inkFile) [0x00064] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaFile.cs:110 
  at Ink.UnityIntegration.InkMetaLibrary.GetInkMetaFile (Ink.UnityIntegration.InkFile inkFile) [0x0006c] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkMetaLibrary.cs:120 
  at Ink.UnityIntegration.InkFile.get_metaInfo () [0x00021] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkFile.cs:26 
  at Ink.UnityIntegration.InkLibrary.RequiresRebuild () [0x00070] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:114 
  at Ink.UnityIntegration.InkLibrary.Validate () [0x00001] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:91 
  at Ink.UnityIntegration.InkLibrary.set_Instance (Ink.UnityIntegration.InkLibrary value) [0x0000d] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:39 
  at Ink.UnityIntegration.InkLibrary.get_Instance () [0x00035] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:32 
  at Ink.UnityIntegration.InkLibrary.Clean () [0x00003] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:140 
  at Ink.UnityIntegration.InkLibrary.Rebuild () [0x00001] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/Ink Library/InkLibrary.cs:168 
  at Ink.UnityIntegration.InkEditorUtils.OnOpenUnityEditor () [0x00001] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/InkEditorUtils.cs:59 
  at Ink.UnityIntegration.InkEditorUtils..cctor () [0x00014] in /Users/rhysvanderwaerden/Projects/ink-unity-integration/Assets/Plugins/Ink/Editor/Core/InkEditorUtils.cs:47 
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes(Type[]) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:118)

I think maybe I should move the package into the Package folder in the new project so this error will be caught there. In fact AFAIK Plugins folder no longer has special support, as evidenced by the fact it's not listed on the "Special Folders" manual page.

rhys-vdw commented 4 years ago

Issue mentioned above were solved by packing the example project into a unitypackage rather than including the story itself in the package.

rhys-vdw commented 4 years ago

@tomkail that's the whole thing done basically. See unchecked items for remaining. Seems to be working nicely.

danielheim commented 4 years ago

Thanks for the prompt action on this.

I checked out your codebase (rhys-vdw:84-unity-package-manager-package), but I'm still having issues with the Custom Editors for when I select an Ink file in Unity. For example, if I select Assets/Ink/story.ink via the Project Explorer, I see a blank Editor. If I select the same file in the source codebase (inkle:master) I see the custom editor with Play button and Ink source code.

I had a play around with the asmdef files, but still no luck.

rhys-vdw commented 4 years ago

Ah, good catch @danielheim. This isn't a feature I've ever used so I hadn't noticed. Guess I'll have to dig into it further.

rhys-vdw commented 4 years ago

@danielheim okay, so I don't understand how all this stuff works, but my guess is that this line is the culprit. A hardcoded list of assemblies that no longer include the integration code.

I can take a look tomorrow. Might need some hints from @tomkail for this one...

rhys-vdw commented 4 years ago

@danielheim got it.

danielheim commented 4 years ago

Awesome! I'll check it out tonight.