Coder Social home page Coder Social logo

ink-unity-integration's Introduction

ink-Unity integration

This Unity package allows you to integrate inkle's ink narrative scripting language with Unity and provides tools to compile, play and debug your stories.

Overview

  • Using ink in your game: Allows running and controlling ink files in Unity via the C# runtime API.

  • ink player: Provides a powerful Ink Player Window for playing and debugging stories.

  • Auto compilation: Instantly creates and updates a JSON story file when a .ink is updated.

  • Inspector tools: Provides an icon for ink files, and a custom inspector that provides information about a file.

Getting started

📥 Installation

There are 4 different ways to install this plugin:

⭐As a .UnityPackage⭐

This will import the source into your Assets folder. This is a good option if you intend to edit the source for your own needs.

As a UPM Package

Installing via a package allows you to easily update via Unity's Package Manager window. This is best if you don't need to edit the source.

  • When installed via UPM, demo projects can be imported from Packages > Ink Unity Integration > Demos

Via Package Manager

  • Add the following line to PROJECT ROOT/Packages/manifest.json: "com.inkle.ink-unity-integration": "https://github.com/inkle/ink-unity-integration.git#upm"

OpenUPM

  • Navigate to OpenUPM and follow their instructions
  • The project will have installed at Packages > Ink Unity Integration.

From GitHub

  • You can clone/download/fork the project on GitHub.
  • The easiest way to download it is to click the green Code button and select Download ZIP
  • Install by moving the folder Packages/Ink to anywhere in your Unity project's Assets folder

Via the Asset Store

For convenience a .UnityPackage is hosted at the Unity Asset Store. This version is updated rarely, and so is not recommended. This will import the source into your Assets folder. This is a good option if you intend to edit the source for your own needs.

🎮 Demos

This project includes a demo scene, providing a simple example of how to control an ink story with C# code using Unity UI.

(If you imported this package as a UPM, then you must first import the demos from Packages > Ink Unity Integration > Demos)

To run a demo, double-click the scene file at the root of the demo folder to open it, and press the Play button at the top of the screen to start it.

📄 C# API

The C# API provides all you need to control ink stories in code; advancing your story, making choices, diverting to knots, saving and loading, and much more.

It is documented in the main ink repo.

For convenience, the package also creates an (Help > Ink > API Documentation) menu option.

✏️ Writing ink

For more information on writing with ink, see the documentation in the main ink repo.

For convenience, the package also creates an (Help > Ink > Writing Tutorial) menu option.

❓ Further Help

For assistance with writing or code, Inkle's Discord forum is full of lovely people who can help you out!

To keep up to date with the latest news about ink sign up for the mailing list.

Features

Compilation

Ink files must be compiled to JSON before they can be used in-game. This package compiles all edited ink files automatically. By default, compiled files are created next to their ink file.

Editor Compilation

This package provides tools to automate this process when a .ink file is edited.

Disabling auto-compilation: You might want to have manual control over ink compilation. If this is the case, you can disable "Compile ink automatically" in the InkSettings file or delete the InkPostProcessor class.

Manual compilation: If you have disabled auto-compilation, you can manually compile all ink files using the Assets > Recompile Ink menu item, individually via the inspector of an ink file, or via code using InkCompiler.CompileInk().

Play mode delay: By default, ink does not compile while in play mode. This can be disabled in the InkSettings file.

In-game Compilation

The compiler is included in builds (See WebGL best practices for information on removing it), enabling you to allow the editing of ink files as part of your game.

Ink Player Window

The Ink Player Window (Window > Ink Player) allows you to play stories in an editor window, and provides functionality to edit variables on the fly, test functions, profile performance, save and load states, and divert.

To play a story, click the "play" button shown on the inspector of a compiled ink file, or drag a compiled ink story TextAsset into the window.

Editor Attaching: Attaching the InkStory instance used by your game to the Ink Player window allows you to view and edit your story as it runs in game.

See BasicInkExampleEditor.cs in the Examples folder for an example of how to:

  • Show an attach/detach button on an inspector
  • Automatically attach on entering play mode

More information on using and extending Ink Player Window

Inspector tools

This package replaces the icon for ink files to make them easier to spot, and adds a custom inspector for a selected ink file.

The Inspector: Selecting an ink file displays its last compile time; lists any include files; and shows any errors, warnings or todos. It also shows a Play button which runs the story in the Ink Player Window.

Visual Scripting Support

Bolt

There is currently no support for Bolt, Unity's official visual scripting tool. If you're interested in building one, we'd love to see it!

PlayMaker

There's unofficial support for PlayMaker here.

We'd love to see this supported more if you'd like to assist the effort!

Source control tips

When you edit ink files, the compiler will also update the corresponding compiled .json file. If no compiled file existed before, Unity will also create a meta file for it. It is recommended that you always commit both ink and json files at the same time to avoid the file being re-compiled by your team members.

Adding or removing ink files will also make changes to the InkLibrary file, and we could recommend authors also commit this file for the same reasons.

WebGL best practices

WebGL builds should be as small as possible. The ink compiler is included in builds, but is typically only used in the editor. If your game doesn't require compiling ink at runtime we recommend adding a .asmdef at Ink Unity Integration > InkLibs > InkCompiler that only functions in the editor.

FAQ

  • Is the Linux Unity Editor supported?

    Yes!

  • What versions of Unity are supported?

    We support 2020 LTS and above. Until version 1.1.1 we supported 2018 LTS, which should also work going back to at least Unity 5.

Support us!:heart:

Ink is free, forever; but we'd really appreciate your support! If you're able to give back, generous donations at our Patreon mean the world to us.

Discord:

Looking for help or want to meet likeminded writers/developers? Come say hello on our Discord server!

License

ink and this package is released under the MIT license. Although we don't require attribution, we'd love to know if you decide to use ink a project! Let us know on Twitter or by email. View the full licence Here

ink-unity-integration's People

Contributors

bncastle avatar dabrowski-adam avatar eveliyse avatar fantabulous-tech avatar gboulard avatar harryr0se avatar horatio-blackwood avatar joaobsneto avatar joethephish avatar joshrickert avatar kumokairo avatar lattyware avatar pvanliefland avatar rhys-vdw avatar rikkhill avatar tomkail avatar tomsh avatar wqa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ink-unity-integration's Issues

many obsolete syntax in unity 2017.x

as you might guessed, it got too many obsolete syntax in your code when i downloaded and imported it on unity 2017.3 for example...

it might be a good idea one of you could create a separate version of ink unity integration. ;) 👍

Customisable mono paths.

Currently there are two hard-coded mono paths that are searched. It would be nice to have this be customisable, or better yet, search PATH for mono by default.

Hide the InkLibrary asset

Given that it's not meant to be deleted, moved or renamed, I feel it would be best to hide the InkLibrary asset in the inspector, and instead only make it viewable via Edit > Ink. This mimics the behaviour of other Unity project settings, such as input.
I've had a quick stab, but failed to get it working. If anybody has experience with HideFlags, feel free to have a go!

PlayMaker integration

How difficult would it be to integrate ink with something like PlayMaker? I'm assuming it wouldn't be impossible, but is this something I could do myself with some Unity scripting or would it be more complicated than that?

Unexpected tag behaviour on choices with square brackets

I'm using the version from the Unity asset store: called 0.7, it appears to be current (for the store).

I'm not getting the behaviour I'd expect from tags when they appear on choices that include square brackets. For example:

-> start
=== start ===
Run this in a player that can show you the tag output. # tag_1
Note which tags appear on which lines. # tag_2
* In this option... # tag_3a
	...Tags appear where the lines (including choice) appear, as I expected # tag_4a
	-> END
* But if you use square brackets[...] in the choice... # tag_3b
	Both tags (3b and 4b) appear on this line. # tag_4b
	-> END

Note that Inky treats tags as part of the string, and the Ink player in the Unity package takes them out properly but doesn't show them. I attach a Unity package with a version of BasicInkExample that appends tags to the output strings (you'll need to import the Unity integration separately). (I typo'd some tag names in the ink that's in the package, but you'll get the point.)

In responses to an issue on the core Ink repository, @joethephish says that tags aren't currently supported on choices. That's fine: I'm reading them when the choice text comes back as content.

He also says:

The main complexity I've seen is the question of how it should interact with the choice structure:
* A [B] C # tag
...since currently we only have tags on the end of a line. So currently that would mean that he tag is added to the content AC. But I guess we could simply also add the tag to the choice AB, which seems like the most straightforward unsurprising approach. Could potentially be awkward if you really don't want the tag on AC though.

But the tag isn't added to the content AC: it arrives with the subsequent line. The tag is read and stripped properly, but something about the square bracket case means that the tag doesn't make it into the state at the point that Joe describes.

Looking at the JSON, tag_4b appears to be stored where I'd expect, so this feels like an issue with the Unity integration's runtime, but I haven't had any luck working out how tags get into the state. (It's hard to confirm completely that it's not a core Ink problem, because I haven't managed to find/make a player that respects tags without using the Unity integration.)

I'm probably going to work around this by putting my tag information into a notation that I can read and strip when the text arrives (i.e. the pre-tags approach), but the project is already complicated and I had hoped to avoid custom notation (and the demands it makes on the writer) now that tags feel like they should be enough.

Compile Error With Ink

"Compiler bug prevented compilation of JSON file" i imported ink into empty unity 5.3.5 project and created new ink file by the right click->create->Ink menu. and it is using the template ink, but when i press compile in custom inspector it opens inklecate window and then says it has stopped responding and gives the error this comment started with. please someone help me fix this error becuase i would love to use ink to make cool games.

  • Ymit

0.6.4 breaks compiling Ink files on Windows

Unhandled error occurred compiling Ink file [InkFile: filePath=Assets/_Story/Episodes/gameplay_demo/gameplay_demo.ink]! Please report following error as a bug:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'ink-engine-runtime, Version=1.0.6198.27218, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at Ink.CommandLineTool..ctor(String[] args)
   at Ink.CommandLineTool.Main(String[] args)

UnityEngine.Debug:LogError(Object)
Ink.UnityIntegration.InkCompiler:Delay() (at Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs:186)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

capture

Compiling Ink files works on my Mac with the same Unity project. Ink 0.6.4, Unity 5.5.0f3. I tried deleting the Ink installation and installing fresh, which did not help.

I tried 0.6.3 which does work so it's probably that compiler refactor mentioned in the release notes.

AssetDatabase doesn't work with StreamingAssets

Right now Unity Inspector can't show "Play" button on compiled Ink file if Ink file located in StreamingAssets folder.

Screenshot

Just because AssetDatabase doesn't work with StreamingAssets folder. To fix this behaviour you can replace AssetDatabase.LoadAssetAtPath with File.ReadAllText to fill inkFile.jsonAsset Also, for this you need to change jsonAsset type from TextAsset to string (maybe?)

[Question/Request] Loading Choices Without Reaching End

The way Ink is set up, choices are always chunked together at the end of a story block. I want to be able to go through the story line by line, and show and hide choices at various points, so that certain ones will appear to be 'time-limited'. It's a technique featured in Ladykiller in a Bind, and I thought it added a whole new dimension to the CYOA style.
Unfortunately, I can't seem to get any choices without reaching the end of the story block. Right now I'm able to accomplish this by using Continue() to reach the end of a block, storing each line in a separate List, getting the choices at the end, and then feeding the player each line from my own List with the choices all stored and ready to go. Actually deciding when certain choices appear or disappear is handled with tags. Here's what that looks like: https://dl.dropboxusercontent.com/u/17586791/Screen%20Shot%202017-02-17%20at%204.02.42%20PM.png
The problem is that every bit of logic in those lines is triggered. I'd love to be able to skip lines by letting the player select a choice before the end of the block, where it would normally appear.

tl;dr: Is there a way to get all the upcoming choices without reaching the end of a story block, or is there a way to Continue() without triggering any logic, or storing logic for later, or any other method that would let me store choices without having to trigger logic on every line?

I realize this is kind of a weird request so I wouldn't be surprised if it isn't possible.

Displaying Story Line by Line

I would like to display the story line by line and put delays between lines. From what I understand Story.Continue() pulls all the text up to the next choice and treats it as one string.

I've seen the code for The Intercept and it seems to me that it just prints this one string letter by letter and inserts delays after certain symbols ("," or ".").

Is there a way to separate the text into lines that can then be displayed one at a time?

Thank you in advance for any tips.

Ink compile bug

I found a bug in InkMetaFile.cs that occurs in the FindIncludeFiles method upon compilation when using this folder/include structure:

Main.ink // INCLUDE Chapter/Chapter.ink (includes main import for each chapter)
Chapter/Chapter.ink // INCLUDE Chapter/Chapter_1.ink (includes multiple parts of chapter 1)
Chapter/Chapter_1.ink // ink content for Chapter 1

The compiler locates Chapter/Chapter.ink just fine, but when it goes locate Chapter/Chapter_1.ink it freaks out because it looks for them relative to their parent Chapter/Chapter.ink instead of the master ink asset Main.ink.

Aka it looks for Chapter/Chapter/Chapter_1.ink instead of Chapter/Chapter_1.ink.

I'm not sure if this is the most appropriate fix, but I replaced the first line in the InkMetaFile.FindIncludeFiles method:

Replaced:

string localIncludePath = InkEditorUtils.CombinePaths(Path.GetDirectoryName(inkFile.filePath), includePath);

With:

string localIncludePath = masterInkAssetPath == "" ?
					Path.GetDirectoryName(inkAssetPath)+"/"+includePath :
					Path.GetDirectoryName(masterInkAssetPath)+"/"+includePath;

And that seems to work just fine.

UPDATE:
The error appears to be a false positive. It seems to compile with the original line of code, but it does throw errors.

[Question] Starting and stopping dialogue

Hello,
I am currently working on a game that features an overarching knowledge system. How it would work is when you interact with something, be it an NPC, bush, sign, etc., certain key words or phrases are highlighted. They then get recorded in the players journal and open up new dialogue options. I really want to use Ink for this project as the state tracking in it will come in handy.

The part i am stuck on right now is how do you deal with ink when not in dialogue. Do you simple create a "Dialogue" state and whenever the game is not in that state it sets the "canContinue" flag to false?

I have read through the Intercept a few times and still cant wrap my head around it.

Thank you in advance!

Question on selecting choices by NPC

Hello,
I have recently started to use Ink, and I am very excited about its amazing capabilities. I am trying to do something rather simple, but I am not sure what would be the best way for doing it. I would like to have a simple dialogue system between the player and an NPC, however I need the NPC to have multiple options to choose from (automatically) based on the state of the player. Is there a way for guide the decision making of the NPC within Ink? or perhaps, adding some script in unity that will reason over the possible options the NPC can select from, and then choosing the most appropriate is a better direction to go?
I would appreciate you help, and my compliments on this amazing work.

Compilation Error when Dropping Multiple Ink files with INCLUDEs Into Unity

OS - Windows 7 64bit
ink-unity-integration version: 0.33

If I drop these three files into an ink/unity project by copying and pasting them from another directory compilation completes but the ink script fails to run in the ink player.

* Steps to reproduce*

  1. Make sure any output Copy and paste the three .ink files into the ink directory in the assets dir of a ink/unity project.
  2. Observe that the compilation cmd windows pop up and go away - no crashes. No errors appear in the Console output.
  3. Observe that two .json files are generated: main.json and state.json.
  4. Select the main.ink file and click the play button in the unity inspector window.
  5. Observe the following error appears in the console.

When I select 'main' and try to run the ink script, I get this error in the console:
NullReferenceException: Object reference not set to an instance of an object
Ink.UnityIntegration.InkPlayerWindow.Play (UnityEngine.TextAsset storyJSONTextAsset) (at Assets/Plugins/Ink/Editor/Player Window/InkPlayerWindow.cs:87)
Ink.UnityIntegration.InkPlayerWindow.LoadAndPlay (UnityEngine.TextAsset storyJSONTextAsset) (at Assets/Plugins/Ink/Editor/Player Window/InkPlayerWindow.cs:70)
Ink.UnityIntegration.InkInspector.OnInspectorGUI () (at Assets/Plugins/Ink/Editor/Ink Inspector/Ink Inspector/InkInspector.cs:106)
Ink.UnityIntegration.ObjectEditor.OnInspectorGUI () (at Assets/Plugins/Ink/Editor/Ink Inspector/Ink Inspector/ObjectEditor.cs:31)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1231)
UnityEditor.DockArea:OnGUI()

state.txt
main.txt
some_ink_file.txt

Changes in Ink not reflected in Unity

When I make changes to my INK file and return to Unity, it compiles successfully, and then the inspector even shows my changes reflected fine when I select the ink file asset. However, when I play the game, none of the changes are reflected! It's simply as though I never made the edits.

Tested this on 3 Macs running OSX and this happened. However, tested it on a PC and it worked fine!

Further, when I did an SVN Commit from the PC and Update from the Mac, it DID work!

Any idea what might be getting stuck when I try to edit the INK file from the Mac?

[guide] Changing the ink menu item's index if you need it.

I recently added a few script templates to my Unity installation, because I'm using a lot of custom editors and scriptable objects, and this happened:
ink-order-templates

As you see, there is no longer a separator before the ink item. This is because my templates use the order space between 90 and 100: the same thing would happen if you created an asset menu item with an order of 95 for example. Though in that case, unless your assets are heavily related to scripts, I'd suggest you change your own order to above 120, because it's way easier.

It's not a problem in itself, so you could ignore it. But if it bothers you, like me, because you heavily rely on the separators to survey a menu, here's what you must change:

  1. Go to Assets/Plugins/Ink/Editor/Tools.
  2. Open the file InkEditorUtils.
  3. Go to line 46. You're looking for this chunk of code:
[MenuItem("Assets/Create/Ink", false, 100)]
        public static void CreateNewInkFile () {
            string fileName = "New Ink.ink";
            string filePath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(GetSelectedPathOrFallback(), fileName));
            CreateNewInkFile(filePath);
        }
  1. Change the 100 value to whatever you need.

small explanation of how menu order indices work
Note that the order of the scene item is 191 and the last shader item has an order of 90 (pseudo-ignored for the separator because its parent menu has the order of the first shader, which is 83).
If you want a separator, you need a gap of at least 11 order indices between two items. So, by default, you have enough space between the scripts "section" and the scene "section" to fit 9 individual separated items, of orders 94, 105, 116, 127, 138, 149, 160, 171, and 182. Remember that if you have nested items, only the smallest order of the whole architecture counts. (on my screenshot, Adventure contains a bunch of items, the smallest being Adventure/Interactions/Generic at 110 (which is why it's not separated from the ink item), and the biggest Adventure/Inventory/Item at 125, though to have a separator to the next item, that item would only need to be of order 121 at least, because Adventure is registered at 110.)

Ink to graph based nodes

Hi guys,

I'm making an adventure game and our team has written the whole script in ink. My idea is to import all the text, diverts, choices from the ink into a FSM (Playmaker). I was able to make it work in simple cases, but when I have more complex structures, the generation leads to very bad results. I think most of the problems is how I implement glue left/right ("<G" or ">G" in JSON) and conditional divert. Do you have any tips on how to iterate over the Story content?
I'm recursively iterating over containers, but when comes to glue, it brakes the code if you have more than one step. Is there some part of the documentation for that?

Thanks!

Remove separate Inklecate files for different platforms and use Compiler.dll directly

EDIT: Original intent of the issue has changed

We've been experiencing this since we've started using Ink. It sometimes locks *.ink for some time and it's impossible to move a file (rarely needed) or change the contents (needed all the time). It usually unlocks after a few "save" tries, but usually takes up to a minute.
Happens on Windows btw, didn't test in on Mac

I just wanted to ask if it's a known problem and we're not the only ones who experience it.

New JSON Path not working

Edit -> Project Settings -> Ink -> New JSON Path.

You can set a path, but the output json will not show up at the expected place.

The feature was added in 0c65763 and I think it was broken in 4c9af71

Readme Lies

It says there isn't Linux Editor support, but 3968d32 adds support and I've personally been using it on Kubuntu 17.10 with the Unity Linux editor.

So that bit in the README should be removed.

How do you get the current path?

I tried most properties that have 'string' or 'path' in the name, but most return empty strings or null references. It seems that story.path.ToString() would would work, but it doesn't. I just want to know what knot/stitch the story is currently at.

Line number

Hello guys,

Is there any way we can track the line number in Unity? We need to track the line number when the player out of the story but we don't know how we can matching the line number and the actual story.

Thanks!!!

Using ink for NPC dialogue

Hi there! I recently stumbled upon ink and have already started tinkering with it. I've fallen in love with how easy it is to write with and how smoothly the unity integration went so kudos to you guys!

I have a few questions regarding whether you think ink is a good fit for standard NPC dialogue within a game and if so, do you have any recommendations as to how to go about structuring things.

The way I've gone about it so far is to have a file with many knots, with each knot being it's own 'conversation' that the player can have with a NPC. I've manually copied the knot names into a list and when the player talks to the NPC, the NPC sets any relevant variables (like player name) and picks a random knot name and uses ChoosePathString("myKnotName") to play the correct 'conversation'.

It's all working perfectly at the moment but later I want certain knots to only be 'pickable' if certain conditions are met (certain point in the game story, NPC emotions, etc). I was thinking of doing this with tags.

So I guess my questions are:
Are you immediately cringing at how I've gone about implementing my current stuff?
If you didn't immediatly cringe, do you recommend any way to automatically get all the knots in a file?
Do you think using tags to differentiate between knot types is a good idea?

Sorry for the wall of text! Thanks!

"Ink Compiler timed out while the file was importing."

I'm running in the Linux editor (2016.3.0f1), and while compilation works (the json is created), I then get this error:

Ink Compiler timed out for /path/to/file.ink while the file was importing.
. Please report as a bug with the following error log at this address: https://github.com/inkle/ink/issues
Error log:
System.Collections.Generic.List`1[System.String]
UnityEngine.Debug:LogError(Object)
Ink.UnityIntegration.InkCompiler:Update() (at Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs:82)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

I've changed the path there, as the original is very long. The only change I've made is to modify the path for mono as on my Linux system it's in /usr/bin/mono.

That error seems to be just printing out the list rather than the content, so I changed the line to:

Debug.LogError("Ink Compiler timed out for "+compilingFile.inkAbsoluteFilePath+" while the file was importing.\n. Please report as a bug with the following error log at this address: https://github.com/inkle/ink/issues\nError log:\n ---"+string.Join(",", compilingFile.errorOutput.ToArray())+"---");

This shows the list is empty:

Ink Compiler timed out for /home/gareth/Work/assets/Assets/Data/OutgoingEmails/SellHeaven.ink while the file was importing.
. Please report as a bug with the following error log at this address: https://github.com/inkle/ink/issues
Error log:
 ------
UnityEngine.Debug:LogError(Object)
Ink.UnityIntegration.InkCompiler:Update() (at Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs:83)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

If I manually run the compiler as the editor is doing, it compiles with no error output and a 0 return code - no errors in sight.

spaces in project names break compiler

Sorry about this: this bug report is a bit of a guess. In the workshop I'm currently in, the blank ink file doesn't compile I think because there is a space in my project name. My project is called "Ink-Unity Workshop" in /home/christophe, and the error message is Cannot open assembly '/home/christophe/Ink-Unity': no such file or directory.

Open at line from inspector opens default script editor, not system default for ink files.

Current call uses UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal, which treats the file as a script file. Ideal behaviour is to open ink files using system default program.
AssetDatabase.OpenAsset does this, but passing in a line number doesn't work, probably because Unity parses the file as a DefaultAsset, rather than a TextAsset.

I've tinkered a bit, but I've got no solutions for this - if anybody does, I'd love to hear it.

Compilation error with unity 5.4 beta

Just a heads up that you'll need to make some changes for Unity 5.4 which is in beta right now. Loading this package into Unity 5.4.0b17 results in 999+ errors of the following:

UnityException: LoadAssetAtPath is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'InkLibrary'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEditor.AssetDatabase.LoadAssetAtPath[InkLibrary] (System.String assetPath) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/AssetDatabaseBindings.gen.cs:210)
Ink.UnityIntegration.InkLibrary.FindOrCreateLibrary () (at Assets/Plugins/Ink/Editor/Ink Library/InkLibrary.cs:66)
Ink.UnityIntegration.InkLibrary..cctor () (at Assets/Plugins/Ink/Editor/Ink Library/InkLibrary.cs:46)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Ink.UnityIntegration.InkLibrary
Ink.UnityIntegration.InkBrowserIcons.OnDrawProjectWindowItem (System.String guid, Rect rect) (at Assets/Plugins/Ink/Editor/Ink Inspector/File Icons/InkBrowserIcons.cs:40)
UnityEditor.ProjectBrowser.OnGUIAssetCallback (Int32 instanceID, Rect rect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ProjectBrowser.cs:585)
UnityEditor.TreeView.DoItemGUI (UnityEditor.TreeViewItem item, Int32 row, Single rowWidth, Boolean hasFocus) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeView.cs:441)
UnityEditor.TreeView.IterateVisibleItems (Int32 firstRow, Int32 numVisibleRows, Single rowWidth, Boolean hasFocus) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeView.cs:568)
UnityEditor.TreeView.OnGUI (Rect rect, Int32 keyboardControlID) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeView.cs:504)
UnityEditor.ProjectBrowser.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/ProjectBrowser.cs:1738)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Looks like a new restriction in 5.4 designed to allow classes to be initially constructed independent of file system assets.

I don't know enough about Ink or Unity to know the impact of moving this code to OnEnable right now, this was my first attempt at playing with it, and I wanted to use Unity 5.4 because it finally supports Retina on my Mac (5.3 is super-ugly ;)). Hope this helps you get out ahead of the official release.

Loads of variable compile errors

I've just downloaded the plugin, having used Inky and the Ink language to create a game. I was hoping to use Unity to make the game playable on Android and IOS (Not even sure if that's possible) but as I put my ink and json file into Unity, I'm getting a lot of "unresolved variable" errors, despite it working just fine in the Inky program and as a HTML file. What do I need to do to fix this?

Infinite Ink Compilation Errors on Unity Startup with version 0.3.4

OS - Windows 7 64bit
ink-unity-integration version: 0.34

When Unity is started with the attached ink files in my assets directory the auto-compile function of the plugin kicks off and results in infinite inklecate compilation errors in the console. In order to stop them, it is necessary to kill Unity.

Its very possible this bug is related to issue #5 , but is manifesting itself differently with the new version of the plugin.

Steps to Reproduce:

1 - Create a project with the new ink-unity plugin in Unity, then close the Unity editor.
2 - Create the following directory ~/Assets/Plugins/Ink/story
3 - Drop in the attached files.
4 - Start Unity and open the project.
5 - Errors begin to appear in the console, it eventually reports "999+" with the following Stack Trace:

NullReferenceException: Object reference not set to an instance of an object
Ink.UnityIntegration.InkInspector.m__1 (Rect rect, Int32 index, Boolean isActive, Boolean isFocused) (at Assets/Plugins/Ink/Editor/Ink Inspector/Ink Inspector/InkInspector.cs:67)
UnityEditorInternal.ReorderableList.DoListElements (Rect listRect) (at C:/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:547)
UnityEditorInternal.ReorderableList.DoLayoutList () (at C:/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:372)
Ink.UnityIntegration.InkInspector.DrawIncludedFiles () (at Assets/Plugins/Ink/Editor/Ink Inspector/Ink Inspector/InkInspector.cs:251)
Ink.UnityIntegration.InkInspector.OnInspectorGUI () (at Assets/Plugins/Ink/Editor/Ink Inspector/Ink Inspector/InkInspector.cs:173)
Ink.UnityIntegration.ObjectEditor.OnInspectorGUI () (at Assets/Plugins/Ink/Editor/Ink Inspector/Ink Inspector/ObjectEditor.cs:33)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1231)
UnityEditor.DockArea:OnGUI()

some_ink_file.txt
state.txt
main.txt

Inkcomplier.cs Error

Getting the following errors from Ink. I am using Unity 5.4.0f1 on Arch Linux.

Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs(167,98): error CS0103: The name `inklecateName' does not exist in the current context
Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs(167,67): error CS1502: The best overloaded method match for `System.IO.Directory.GetFiles(string, string, System.IO.SearchOption)' has some invalid arguments
Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs(167,67): error CS1503: Argument `#2' cannot convert `object' expression to type `string'

Newest version of ink not available in Unity's asset store

I just want you to know that the newest version of ink is not available in Unity's asset store. I see that the current version is now 0.4.0. The version available in Unity's asset store is right now 0.3.51, which I downloaded first and experienced a compile error like this one: #16

Luckily, I figured out on that forum thread that a new, working version of ink was available here (0.4.0): https://github.com/inkle/ink/releases/tag/0.4.0

It would be nice if you could upload newest version to Unity's asset store, so that other newcomers (in Unity) do not get scared away from using ink due to compile error.

No feedback on ink compilation success after failure

When an ink error occurs, the following kind of message appears in the status bar at the bottom of the Unity editor:

ink-error

However, upon fixing the error in an editor and switching back to Unity, this line doesn't go away, which leads me to believe that something is still wrong with the file. It's only by going to the Console window and clicking "Clear" before making changes to the .ink script that I can confirm that no errors occurred on compilation, which seems unintuitive and inefficient.

Perhaps a message like "Auto-compilation of [filename].ink successful" should appear whenever compilation succeeds?

Note that this might actually be a bug with Unity itself; I've noticed that a similar kind of problem exists with Unity's built-in Editor Tests Runner. If that's the case, feel free to close this issue!

Compiling .ink files in Windows for Unity throws an Exception

I'm running Unity 5.3.5f1 for Windows. When do a clean pull of the ink-unity-integration project, and try to compile an inkfile (such as Basic/story.ink) I get the following error:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at Ink.Runtime.Story.ToJsonString(Boolean indented)
   at Ink.CommandLineTool..ctor(String[] args)
   at Ink.CommandLineTool.Main(String[] args)

UnityEngine.Debug:LogError(Object)
Ink.UnityIntegration.InkCompiler:Delay() (at Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs:173)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

From my understanding, Unity3d's current Mono framework version only supports dlls compiled for .NET Framework 3.5 or earlier. Looking at the Nuget packages.config files for the Visual Studio solution, they specify different target frameworks for Newtonsoft.Json.dll in the ink-engine-dll and inklecate projects. For the ink-engine-dll project, it's "net35". For the inklecate project, it's "net45" which is fine ... until you bring inklecate_win.exe and ink-engine.dll into Unity and throw them in the same directory. They both want different Newtonsoft.Json dlls for different framework targets and this causes the issue.
diffdlls

If I'm not mistaken you have moved some files around yes? I'm betting you don't see this behavior on Mac OS, but I'm not sure why exactly. I only know that it happens in Windows. If I separate both inklecate_win.exe and ink-engine.dll into their own directories and give them the Newtsonsoft.Json.dlls they want, all is well. Then of course there are two Json dlls hanging around which feels icky.

Update: The solution is to compile Inklecate using the .NET 3.5 version of the Netwonsoft dll and all is well. This requires some changes in the VS solution file.

Error compiling

I'm having problems compiling your test story ('Assets/Plugins/Ink/Example/Ink/story.ink').
I get the following errors:

Ink compilation completed with errors at 10:58:50 PM
Files compiled:
Assets/Plugins/Ink/Example/Ink/story.ink (With unhandled error)
UnityEngine.Debug:LogWarning(Object)
Ink.UnityIntegration.InkCompiler:Delay() (at Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs:288)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

Error compiling inks on Unity plugin, using Unity 2017.03.0f3

Hello, I downloaded the Unity integration from the asset store, and tried to compile my first .ink file, and got the following error:

Unhandled error(s) occurred compiling Ink file 'Assets/Plugins/Ink/Example/Ink/story.ink'! Please report following error(s) as a bug:


UnityEngine.Debug:LogError(Object)
Ink.UnityIntegration.InkCompiler:Delay() (at Assets/Plugins/Ink/Editor/Compiler/InkCompiler.cs:245)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

I tried downloading the latest unity package release from your site as well (0.7.4), but I'm getting the same error. If I try to recompile the example .ink (Ink/Example/Ink/story.ink) I get the same error, so I don't think it's a syntax error or other issue specific to my ink.

Detecting if stitch/knot has been visited before

Hello,

My team is currently implementing a fastforward/skip feature for when dialog has been read before dynamically but haven't found an easy way in the current Ink API to do so; There's VisitCountatPathString which works if I know the knot ahead of time, but since we have many story files with many knots the approach is unsustainable.

We would very much appreciate a way to know on what stitch/knot we are currently on every line read. At least that way we could perhaps query the visit counts? Right now our approach is the following:

image

It obviously... doesn't make me very happy. Is there a better way?

UNHANDLED EXCEPTION

[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object

Not entirely sure what I did to make this happen but any clues on where to start would be greatly appreciated!

Thanks.

`Todo` in InkCompiler.cs

Hello.

I was looking up my Visual Studio Task window and I saw this:

Priority Description File Line
Normal Todo - switch this to pendingFile.inkFile.includesInkFiles InkCompiler.cs 225

Is this something we user have to ignore, or should we care about it?
It's present in the 0.4.0 unitypackage release over at inkle/ink.

EDIT:
I found it in the file in this repo, actually line 228.

Welding to choice output concatenates without space.

If I put a weld <> at the end of a line, and follow that up with some choices, this almost does what I would expect. It neatly omits the linefeed from the end of the text provided by ContinueMaximally -- which is great! What is not so great is that it fails to put any space at the end of the line, so my words end up running together.

For instance, if I have:

Hi, my name is <>
* John
* Paul
* George
* Ringo

...and I select "Paul," this would result in:

Hi, my name isPaul

As a workaround, for now, I can manually look for lines that end in a non-whitespace character, and plunk a space in there. It's ugly, but I think it will get the job done. I just wanted to send a note along, in case it helps.

A lot of unnecessary using directives

Omnisharp is complaining about a lot of unused "using" directives. It's harmless but it adds a lot of noise to my "Problems" panel in my editor. I'd be happy to run an automated cleanup and submit a pull request if that would be welcome.

Compilation Error With Unity-Integrated Auto-Recompile

cheesey_diagram
some_ink_file.txt
state.txt
main.txt

The issue seems to arise when making changes to the some_ink_file.ink file that causes a recompile but for some reason, values in the state.ink file aren't being read or included in the recompile somehow. Could be in the code that provides the list of files to give the compiler or barring that, it could be in the compiler itself.

Steps -
1 - start unity - drop these into an empty project with unity plugin.
2 - Compile main, run it and see that it works.
3 - Tweak some_ink_file.ink (just add a space or something) and save.
4 - observe error in console "Unresolved Variable" char_name

Make compiled JSON a sub asset of .ink files.

To keep the assets hierarchy panel a bit clearer, I'd like to nest compiled JSON inside of the .ink file as a child, in the same way that a sprite is a child of a texture.
I've had a tinker, but failed to get this working - it's not a particularly well documented feature.
If it's the case that you can't nest in files that aren't ScriptableObjects, suggest that we instead convert InkFile to a ScriptableObjects and nest both the .ink and the .json inside of it. This would be a pretty massive change, so we're in no rush.
I'd like to hear any thoughts on this problem, if you've got them!

[Question] Is it possible to load external ink/json file once unity game is builded?

I'd like to edit ink file once unity game is builded to make changes on writer side (and view it re-executing game or pushing some button to refresh ink story). It'd be useful for the writer not to have to install unity.

I've readed InkComplier and InkLibrary but it's a bit complicated to understand easily for me. I think that could work adding new (external) InkFile to InkLibrary.

If this is possible, Can you advise me on the next steps?

Maybe I'm losing something...

Thank you in advance and for your work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.