This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MK-docs documentation for use in ReadTheDocs.
Updated to include develop changes compared to gh-pages documentation. Refer to #46 for more information.
- Loading branch information
Seneral
committed
Sep 4, 2016
1 parent
c97553c
commit d05ff80
Showing
16 changed files
with
413 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
# Custom Input Controls | ||
|
||
*NOTE: In the latest development branch, the Input system has been completely revamped. The following is not valid for older versions!* <br> | ||
For your Editor Extension you might want to add custom controls or functions to the context clicks of both the canvas and the editor. | ||
Using the new dynamic Input system it is very easy to do just that using four provided attributes which can be stacked as you wish. | ||
Before explaining these in detail, it might be worth checking the default controls out in `NodeEditorInputControls`! | ||
<br> | ||
|
||
#### <u>NodeEditorInputInfo</u> | ||
|
||
The primary information container, `NodeEditorInputInfo`, contains all informations about an event including the editorState, the mouse position or the invoking event. | ||
It is used to provide all necessary information to the dynamic input handlers. | ||
<br> | ||
|
||
#### <u>EventHandler Attribute</u> | ||
|
||
The `EventHandlerAttribute` is used to handle arbitrary events for the Node Editor and is the most flexible attribute. | ||
Some default controls like Node dragging, panning, zooming and Node connecting could only be implemented using this attribute. | ||
Tagging a static function with this attribute makes it get called when the specified 'EventType' occurs (or always when no event specified). | ||
The optional variable `priority`, next to the constructor variations, primarily defines the order of execution, but also a way to execute the input after the GUI (priority >= 100). | ||
The method signature **must** be as follows:[ Return: Void; Params: NodeEditorInputInfo ] | ||
<br> | ||
|
||
#### <u>Hotkey Attribute</u> | ||
|
||
The `HotkeyAttribute` is used to provide a simple interface for hotkeys for the Node Editor. | ||
Some default controls like Navigating ('N') and Snapping ('Control') are implemented using this attribute | ||
It allows you to specify a `KeyCode` / `EventModifier` combination with a limiting `EventType` to specify when the tagged static function gets called. | ||
Again, the optional variable `priority` can be specified. Refer to the `EventHandlerAttribute` for it's effect. | ||
The method signature **must** be as follows:[ Return: Void; Params: NodeEditorInputInfo ] | ||
<br> | ||
|
||
#### <u>ContextEntry Attribute</u> | ||
|
||
The `ContextAttribute` is used to register context entries for the Node`Editor. | ||
The tagged function is called when the context element at the specified path is selected. | ||
In which context menu to add this element is specified by the type, like the node context click or the canvas context click. | ||
The method signature **must** be as follows:[ Return: Void; Params: NodeEditorInputInfo ] | ||
<br> | ||
|
||
#### <u>ContextFiller Attribute</u> | ||
|
||
The `ContextFillerAttribute` is used to register context entries in the Node Editor in a dynamic, conditional or procedural way. | ||
This function will be called to fill the passed context `GenericMenu` in any way it likes to. | ||
Again the type specifies the context menu to fill. | ||
The method signature **must** be as follows:[ Return: Void; Params: NodeEditorInputInfo, GenericMenu ] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
# Custom NodeCanvas | ||
|
||
*NOTE: This is experimental and has not reached it's final state yet, many more features to come! This sections is very WIP!* <br> | ||
It is possible to create custom NodeCanvas types to limit specific nodes to. For example, you can create a Dialogue canvas type with own, specific properties and even own traversal routines. | ||
Simply extend the NodeCanvas class and change properties. An example can be found on the branch *[Examples/Dialogue System](https://github.com/Baste-RainGames/Node_Editor/tree/Examples/Dialogue-System)* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
# Building a custom Editor | ||
|
||
The provided Editor Window serves as the default Node Canvas Explorer for all dependant extensions that gets the job done. | ||
But in order to make extensions that are built on top of this Framework unique, you'll sooner or later need to built your own Editor Interface. | ||
The following outlines the most important things to consider in order to build a basic Node Editor Interface in both Runtime and the Editor. | ||
|
||
<br> | ||
|
||
### The Canvas and Editor States | ||
|
||
The Editor obviously has to stores the currently opened NodeCanvas and it's NodeEditorState in the first place. | ||
For a detailed explanation of these, please look up the [Framework Overview](FrameworkOverview.md). <br> | ||
`NodeEditorUserCache` is a wrapper class to aid your extension managing the canvas and editor state. For the majority of cases, it is perfectly fine. | ||
The easy API for saving/loading and even caching in the editor works both in the editor and at runtime. | ||
|
||
<br> | ||
|
||
### The Canvas GUI | ||
|
||
For the GUI to look the same in the whole window and to allow for custom popups in your GUI, you first need to call `NodeEditorGUI.StartNodeGUI`. At the end you need to call `NodeEditorGUI.EndNodeGUI`. <br> | ||
Before you can draw the canvas area, first make sure a canvas is loaded and assign the rect for the canvas area to your `NodeEditorState.canvasRect` property. | ||
Also, not that modifying the `GUI.matrix` scale while when drawing the canvas area is not yet supported. <br> | ||
In order to best account for errors that may be thrown, the drawing function should be embedded in a try-catch block that unloads the canvas when an error was thrown. | ||
Make sure you only catch `UnityExceptions` though, because of a Unity bug all pickers like `ColorField`, `CurveField` or `ObjectField` will throw an error when inside a `System.Exception` try-catch-block. <br> | ||
In this try-catch-block you can safely call `NodeEditor.DrawCanvas`, passing both the `NodeCanvas` and the `EditorState`, in order to draw the canvas in the specified area. | ||
All additional interface elements like toolbar, side panel, etc. are up to you to handle, and are easily filled using the API of the Framework. | ||
|
||
<br> | ||
|
||
### Custom GUI Skin | ||
|
||
The GUISkin of the Node Editor can currently only be changed by modifying the `NodeEditorGUI` source file or by replacing the textures. | ||
For the future a more extensive and separated control over the GUISkin is planned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# Custom ConnectionTypes | ||
|
||
Implementing custom ConnectionTypes is similar to Node implementation, as it uses the same fetching system: | ||
Declare a class inheriting from the `IConnectionTypeDeclaration` interface and specify it's properties. | ||
|
||
<center> | ||
![ConnectionType with IConnectionTypeDeclaration] (/img/ConnectionTypes.png "ConnectionTypes.cs: Top: IConnectionTypeDeclaration; Bottom: Built-in Float type") | ||
<br> | ||
ConnectionTypes.cs: Top: IConnectionTypeDeclaration; Bottom: Built-in Float type | ||
</center> | ||
|
||
- The `string Identifier` is used to address the type | ||
- The `Type Type` is the type this declaration representates and which is used to check for connection compability | ||
- The `Color Color` is the color associated with the type, in which the knob textures as well as the connections are tinted with | ||
- The strings `InKnobTex` and `OutKnobTex` are the paths to the knob textures relative to '_Node\_Editor/Resources_'. Defaults are '_Textures/In\_Knob.png_' and '_Textures/Out\_Knob.png_' | ||
|
||
Do not that the names may differ in previous versions! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
# Custom Nodes | ||
|
||
The implementation of additional, custom nodes is fairly easy. You have to create a script anywhere in the project extending the `NodeEditorFramework.Node` class. | ||
It will provide the Framework all needed information about the node itself, the optional `Node` attribute contains information about the presentation in the editor. | ||
The Framework will search all script assemblies for additional nodes, so extra setup is not required. If you do need a custom assembly to be included, you can add it manually in `NodeTypes.cs`. | ||
|
||
The following outlines the necessary Node members. You can take reference from the ExampleNode found in '*Plugins/Node_Editor/Nodes/Example*'. | ||
First to mention is that even though the Framework is programmed in C#, you can add nodes in UnityScript with the limitation that they have to be compiled in phase 2,3 or 4, | ||
as described [here](http://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html). Therefore the following members are described language independently. | ||
|
||
- import/use `NodeEditorFramework` | ||
- Class extending `Node` | ||
- _Optional_: Attribute `Node` *[params: [Bool] hide; [String] contextPath; optional [Type] canvasType]* | ||
- Unique Node ID; declare: `ID` *[constant string]*; expose: property `GetID`*[Override]* | ||
- _Optional_: Behaviour Options | ||
- `AllowRecursion` *[override, default: false]* | ||
- `ContinueCalculation` *[override, default: true]* | ||
- `AcceptsTransitions` *[override, default: false]* | ||
- Method `Create` *[override; Params: [Vector2] position; Returns : [Node] created node]* | ||
- Create a new Node of your type using `CreateInstance` and assign it's property `rect` using the position parameter | ||
- Add connections using `CreateInput`/`CreateOutput` or `NodeInput.Create`/`NodeOuput.Create` *[Params: name; type ID; side; position]* | ||
- Perform any other additional setup steps and return your created node | ||
- Method `NodeGUI` *[protected (internal) override]* | ||
- Draw your Node's GUI; you may use GUILayout functions | ||
- Access the Inputs/Outputs using the respective arrays in the order of creation. | ||
Use their methods `DisplayLayout` or `SetPosition` to position (and draw) them. | ||
- Method `Calculate` *[override]* | ||
- The methods `allInputsReady`, `hasUnassignedInputs` and `descendantsCalculated` | ||
may help to check if the node is ready, based on the needs and purposes of it. | ||
- Get the input values by calling `GetValue` on the NodeInputs and set the output values with `SetValue` the same way. | ||
- Return _true_ when you're done calculating and _false_ when you are not ready yet and need another attempt. | ||
But be aware, you cannot yield calculation that way, after a maximum of a _thousand_ repeated tries the calculation will be aborted! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
# Events | ||
|
||
The Framework supports a collection of events which might be important during the editing process. | ||
Those Events can either be received by subscribing to the appropriate delegate in the NodeEditorCallbacks class | ||
or by extending from NodeEditorCallbackReceiver (which is a MonoBehaviour) and overriding the appropriate method. | ||
Both classes can be found in `NodeEditorCallbackReceiver` <br> | ||
##### Current Events | ||
|
||
- `OnEditorStartup` : The Node Editor gets initiated (can also happen when switching scene or playmode) | ||
- `OnLoadCanvas` (NodeCanvas): The passed canvas has been loaded as a copy | ||
- `OnLoadEditorState` (NodeEditorState): The passed editorState has been loaded as a copy | ||
- `OnSaveCanvas` (NodeCanvas): The passed canvas has been saved as a copy | ||
- `OnSaveEditorState` (NodeEditorState): The passed editorState has been saved as a copy | ||
<br> <br> | ||
- `OnAddNode` (Node): The passed node has been created or duplicated | ||
- `OnDeleteNode` (Node): The passed node will get deleted | ||
- `OnMoveNode` (Node): The passed node has been moved by the user | ||
<br> <br> | ||
- `OnAddConnection` (NodeInput): A new connection has been added to the passed input. If it had a connection before, *OnRemoveConnection* has been called, too | ||
- `OnRemoveConnection` (NodeInput): The connection will get removed from this input | ||
<br> <br> | ||
##### WIP Transitioning System: | ||
- `OnAddTransition` (Transition): The passed transition has been created | ||
- `OnRemoveTransition` (Transition): The passed transition will be removed | ||
|
||
<br> | ||
|
||
-> Some of the Node-specific callbacks can also be accessed from the Node directly by overriding the appropriate method. | ||
<br> | ||
-> You can always implement additional callbacks or request them to be implemented! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
# Building Extensions - Overview | ||
|
||
These pages will guide you to create your own extension without touching the framework code. | ||
This is possible by dynamically fetching extending content from all assemblies and even enables user extensions. | ||
<br> | ||
If you want/need to create modify the framework for your extension, you can refer to the [Framework Overview](../FrameworkOverview.md) to get a glimpse on how each framework part works. | ||
|
||
<br> | ||
|
||
## Covered Topics | ||
<br> | ||
<span style="font-size:1.1em;"> | ||
- __ [Custom Nodes](CustomNodes.md)__ - Implementation of custom Nodes | ||
<br><br> | ||
- __ [Custom ConnectionTypes](CustomConnectionTypes.md)__ - Defining custom ConnectinTypes in order to pass custom types with customized visualization | ||
<br><br> | ||
- __ [Adding NodeCanvas Types](AddingNodeCanvasTypes.md)__ - Implementation of custom NodeCanvas Types for customized situations | ||
<br><br> | ||
- __ [Adding Input Controls](AddingInputControls.md)__ - Addition of Input Controls to the dynamic Input System with Attribbutes | ||
<br><br> | ||
- __ [Building an Editor](BuildingAnEditor.md)__ - Building of a custom Editor Window or other user of the Node Editor Framework | ||
<br><br> | ||
- __ [Event & Callbacks](EventsCallbacks.md)__ - Making use of the framework events and callbacks | ||
<br><br> | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
# Framework Overview | ||
|
||
*(NOTE: This page is WIP)* | ||
|
||
This section aims to bring you a decent overview on how the framework is structured, so you can get to modify it quickly. | ||
This does not necessarily include implementation details – code sections that need extra detailing are commented. | ||
Also, this section is not only for those planning to get into the code, but for everyone to get an overview what he's working with:) | ||
|
||
<br> | ||
|
||
### `NodeCanvas` and `NodeEditorState` | ||
|
||
Those two components essentially make up the save file you can load up into the Editor. | ||
Basically, the canvas stores all the nodes and any additional information directly related to the Canvas. | ||
In contrary, the `EditorState` holds all information on the state, or in other words, on how the Canvas is presented. | ||
This includes zoom and pan values, selected Nodes, the canvasRect, etc. Not all of these values are actually saved with the asset, though. | ||
That structure allows for multiple 'views' on the same Canvas and editing it simultaneously. | ||
|
||
<br> | ||
|
||
### The `DrawCanvas` function | ||
|
||
This function acts very similar to any other GUI control, with a few exceptions, and is responsible for drawing the Canvas. | ||
On the first glance it's just a wrapper for `DrawSubCanvas`, with the exception that it holds the `OverlayGUI` and `NodeGUISkin` code. | ||
`DrawSubCanvas` is used in the future for Nested Canvases, as the name proposes. | ||
|
||
First of all, the background texture is splattered across the canvas area based on zoom and pan values. | ||
Then, the function `NodeEditorInputSystem.HandleInputEvents` invokes all dynamic input handlers of the input system to catch all kinds of Input events. | ||
|
||
Afterwards the scale area gets initiated with a call to the custom solution `GUIScaleUtility.BeginScale`. <br> | ||
Any GUI code afterwards is getting scaled appropriately. | ||
That means that now all elements that need to be scaled are drawn, including connections, node transitions, connections, bodies and knobs. <br> | ||
Thereafter, the scale area gets closed again with another call to `GUIScaleUtility.EndScale`. | ||
|
||
The `NodeEditorInputSystem.HandleLateInputEvents` function then invokes the dynamic input handlers similar to the version before, | ||
with the exception that only those that have to be handled after GUI are invoked. | ||
|
||
<br> | ||
|
||
#### <u>Framework Part explanations planned</u> | ||
- Dynamic Input System at `NodeEditorInputSystem` | ||
- ConnectionType and Node fetching at `NodeTypes` and `ConnectionTypes` | ||
- Knob Behaviour and Possibilities at `NodeKnob` | ||
- Event/Callback System at `NodeEditorCallbackReceiver` | ||
- Save System at `NodeEditorSaveManager` | ||
- Various Utilities like `GUIScaleUtility` | ||
- Calculation System at `NodeEditor` | ||
- Transitioning System including UnityFunc if they are ready | ||
- Runtime GUI and limitations at `RTEditorGUI` mostly | ||
- Experimental/Conceptional custom NodeCanvases and traversal algorithms | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
# Getting Started | ||
|
||
<br> | ||
|
||
## Installation | ||
Installing is as simple as dragging and dropping the *Editor* and *Node_Editor* folders into your project at *Assets/Plugins*. It will work anywhere but would require a change in source for long term usage. | ||
You are then able to open the window at '*Window/Node Editor*' when there are no errors in the project. | ||
|
||
|
||
<br> | ||
|
||
## Examples | ||
|
||
### Editor & Canvas | ||
You can start off by opening the Editor Window at '*Window/Node Editor*' and loading an example canvas, such as the *CalculationCanvas*. | ||
Use either the button at the top right or locate it in the project folder and double-click it. | ||
|
||
Using context-clicks you can manipulate the canvas, using drag'n'drop you can drag around and connect node outputs and inputs with each other. | ||
`Control` will snap nodes to the grid and `N` will help you navigate back to the origin or the selected node! | ||
|
||
### Example Extensions | ||
For examples on simple extensions, check out all '*Examples/*'-Subbranches on the repository! <br> | ||
One of the currently available examples is the [Texture Composer](https://github.com/Baste-RainGames/Node_Editor/tree/Examples/Texture_Composer), | ||
an example of adding Nodes and ConnectionTypes to extend the framework to simple texture manipulation capabilities. <br> | ||
Another is the [Dialogue System](https://github.com/Baste-RainGames/Node_Editor/tree/Examples/Dialogue-System), | ||
which demonstrates the actual usage of a canvas at runtime to drive a simple dialogue. | ||
|
||
### Example Runtime Usage | ||
For more general ideas on how to use the canvas at runtime, you can check out `RTCanvasCalculator`, which is a component that can | ||
calculate and debug the canvas at runtime and also implements some basic but useful helper functions to traverse the canvas at runtime. <br> | ||
It is also possible to show the actual GUI at runtime, as `RuntimeNodeEditor` demonstrates. It works and looks very similar to the editor window | ||
with some limitations due to inaccessibility to the UnityEditor namespace. But aslong as the Nodes use `RTEditorGUI` for available UI controls | ||
and encapsulate all editor-only GUI parts into a preprocessor checks, it is totally possible to give your player access to a Node Editor:) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Software license | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Baste Nesse Buanes | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ul.nav.navbar-nav:not(.navbar-right) > li:first-child { | ||
display: none; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.