Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit d05ff80

Browse files
author
Seneral
committed
MK-docs documentation for use in ReadTheDocs.
Updated to include develop changes compared to gh-pages documentation. Refer to #46 for more information.
1 parent c97553c commit d05ff80

16 files changed

+413
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
# Custom Input Controls
3+
4+
*NOTE: In the latest development branch, the Input system has been completely revamped. The following is not valid for older versions!* <br>
5+
For your Editor Extension you might want to add custom controls or functions to the context clicks of both the canvas and the editor.
6+
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.
7+
Before explaining these in detail, it might be worth checking the default controls out in `NodeEditorInputControls`!
8+
<br>
9+
10+
#### <u>NodeEditorInputInfo</u>
11+
12+
The primary information container, `NodeEditorInputInfo`, contains all informations about an event including the editorState, the mouse position or the invoking event.
13+
It is used to provide all necessary information to the dynamic input handlers.
14+
<br>
15+
16+
#### <u>EventHandler Attribute</u>
17+
18+
The `EventHandlerAttribute` is used to handle arbitrary events for the Node Editor and is the most flexible attribute.
19+
Some default controls like Node dragging, panning, zooming and Node connecting could only be implemented using this attribute.
20+
Tagging a static function with this attribute makes it get called when the specified 'EventType' occurs (or always when no event specified).
21+
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).
22+
The method signature **must** be as follows:[ Return: Void; Params: NodeEditorInputInfo ]
23+
<br>
24+
25+
#### <u>Hotkey Attribute</u>
26+
27+
The `HotkeyAttribute` is used to provide a simple interface for hotkeys for the Node Editor.
28+
Some default controls like Navigating ('N') and Snapping ('Control') are implemented using this attribute
29+
It allows you to specify a `KeyCode` / `EventModifier` combination with a limiting `EventType` to specify when the tagged static function gets called.
30+
Again, the optional variable `priority` can be specified. Refer to the `EventHandlerAttribute` for it's effect.
31+
The method signature **must** be as follows:[ Return: Void; Params: NodeEditorInputInfo ]
32+
<br>
33+
34+
#### <u>ContextEntry Attribute</u>
35+
36+
The `ContextAttribute` is used to register context entries for the Node`Editor.
37+
The tagged function is called when the context element at the specified path is selected.
38+
In which context menu to add this element is specified by the type, like the node context click or the canvas context click.
39+
The method signature **must** be as follows:[ Return: Void; Params: NodeEditorInputInfo ]
40+
<br>
41+
42+
#### <u>ContextFiller Attribute</u>
43+
44+
The `ContextFillerAttribute` is used to register context entries in the Node Editor in a dynamic, conditional or procedural way.
45+
This function will be called to fill the passed context `GenericMenu` in any way it likes to.
46+
Again the type specifies the context menu to fill.
47+
The method signature **must** be as follows:[ Return: Void; Params: NodeEditorInputInfo, GenericMenu ]
48+
49+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
# Custom NodeCanvas
3+
4+
*NOTE: This is experimental and has not reached it's final state yet, many more features to come! This sections is very WIP!* <br>
5+
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.
6+
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)*
7+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Building a custom Editor
3+
4+
The provided Editor Window serves as the default Node Canvas Explorer for all dependant extensions that gets the job done.
5+
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.
6+
The following outlines the most important things to consider in order to build a basic Node Editor Interface in both Runtime and the Editor.
7+
8+
<br>
9+
10+
### The Canvas and Editor States
11+
12+
The Editor obviously has to stores the currently opened NodeCanvas and it's NodeEditorState in the first place.
13+
For a detailed explanation of these, please look up the [Framework Overview](FrameworkOverview.md). <br>
14+
`NodeEditorUserCache` is a wrapper class to aid your extension managing the canvas and editor state. For the majority of cases, it is perfectly fine.
15+
The easy API for saving/loading and even caching in the editor works both in the editor and at runtime.
16+
17+
<br>
18+
19+
### The Canvas GUI
20+
21+
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>
22+
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.
23+
Also, not that modifying the `GUI.matrix` scale while when drawing the canvas area is not yet supported. <br>
24+
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.
25+
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>
26+
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.
27+
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.
28+
29+
<br>
30+
31+
### Custom GUI Skin
32+
33+
The GUISkin of the Node Editor can currently only be changed by modifying the `NodeEditorGUI` source file or by replacing the textures.
34+
For the future a more extensive and separated control over the GUISkin is planned.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
# Custom ConnectionTypes
3+
4+
Implementing custom ConnectionTypes is similar to Node implementation, as it uses the same fetching system:
5+
Declare a class inheriting from the `IConnectionTypeDeclaration` interface and specify it's properties.
6+
7+
<center>
8+
![ConnectionType with IConnectionTypeDeclaration] (/img/ConnectionTypes.png "ConnectionTypes.cs: Top: IConnectionTypeDeclaration; Bottom: Built-in Float type")
9+
<br>
10+
ConnectionTypes.cs: Top: IConnectionTypeDeclaration; Bottom: Built-in Float type
11+
</center>
12+
13+
- The `string Identifier` is used to address the type
14+
- The `Type Type` is the type this declaration representates and which is used to check for connection compability
15+
- The `Color Color` is the color associated with the type, in which the knob textures as well as the connections are tinted with
16+
- 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_'
17+
18+
Do not that the names may differ in previous versions!
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
# Custom Nodes
3+
4+
The implementation of additional, custom nodes is fairly easy. You have to create a script anywhere in the project extending the `NodeEditorFramework.Node` class.
5+
It will provide the Framework all needed information about the node itself, the optional `Node` attribute contains information about the presentation in the editor.
6+
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`.
7+
8+
The following outlines the necessary Node members. You can take reference from the ExampleNode found in '*Plugins/Node_Editor/Nodes/Example*'.
9+
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,
10+
as described [here](http://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html). Therefore the following members are described language independently.
11+
12+
- import/use `NodeEditorFramework`
13+
- Class extending `Node`
14+
- _Optional_: Attribute `Node` *[params: [Bool] hide; [String] contextPath; optional [Type] canvasType]*
15+
- Unique Node ID; declare: `ID` *[constant string]*; expose: property `GetID`*[Override]*
16+
- _Optional_: Behaviour Options
17+
- `AllowRecursion` *[override, default: false]*
18+
- `ContinueCalculation` *[override, default: true]*
19+
- `AcceptsTransitions` *[override, default: false]*
20+
- Method `Create` *[override; Params: [Vector2] position; Returns : [Node] created node]*
21+
- Create a new Node of your type using `CreateInstance` and assign it's property `rect` using the position parameter
22+
- Add connections using `CreateInput`/`CreateOutput` or `NodeInput.Create`/`NodeOuput.Create` *[Params: name; type ID; side; position]*
23+
- Perform any other additional setup steps and return your created node
24+
- Method `NodeGUI` *[protected (internal) override]*
25+
- Draw your Node's GUI; you may use GUILayout functions
26+
- Access the Inputs/Outputs using the respective arrays in the order of creation.
27+
Use their methods `DisplayLayout` or `SetPosition` to position (and draw) them.
28+
- Method `Calculate` *[override]*
29+
- The methods `allInputsReady`, `hasUnassignedInputs` and `descendantsCalculated`
30+
may help to check if the node is ready, based on the needs and purposes of it.
31+
- Get the input values by calling `GetValue` on the NodeInputs and set the output values with `SetValue` the same way.
32+
- Return _true_ when you're done calculating and _false_ when you are not ready yet and need another attempt.
33+
But be aware, you cannot yield calculation that way, after a maximum of a _thousand_ repeated tries the calculation will be aborted!
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# Events
3+
4+
The Framework supports a collection of events which might be important during the editing process.
5+
Those Events can either be received by subscribing to the appropriate delegate in the NodeEditorCallbacks class
6+
or by extending from NodeEditorCallbackReceiver (which is a MonoBehaviour) and overriding the appropriate method.
7+
Both classes can be found in `NodeEditorCallbackReceiver` <br>
8+
##### Current Events
9+
10+
- `OnEditorStartup` : The Node Editor gets initiated (can also happen when switching scene or playmode)
11+
- `OnLoadCanvas` (NodeCanvas): The passed canvas has been loaded as a copy
12+
- `OnLoadEditorState` (NodeEditorState): The passed editorState has been loaded as a copy
13+
- `OnSaveCanvas` (NodeCanvas): The passed canvas has been saved as a copy
14+
- `OnSaveEditorState` (NodeEditorState): The passed editorState has been saved as a copy
15+
<br> <br>
16+
- `OnAddNode` (Node): The passed node has been created or duplicated
17+
- `OnDeleteNode` (Node): The passed node will get deleted
18+
- `OnMoveNode` (Node): The passed node has been moved by the user
19+
<br> <br>
20+
- `OnAddConnection` (NodeInput): A new connection has been added to the passed input. If it had a connection before, *OnRemoveConnection* has been called, too
21+
- `OnRemoveConnection` (NodeInput): The connection will get removed from this input
22+
<br> <br>
23+
##### WIP Transitioning System:
24+
- `OnAddTransition` (Transition): The passed transition has been created
25+
- `OnRemoveTransition` (Transition): The passed transition will be removed
26+
27+
<br>
28+
29+
-> Some of the Node-specific callbacks can also be accessed from the Node directly by overriding the appropriate method.
30+
<br>
31+
-> You can always implement additional callbacks or request them to be implemented!
32+

Docs/BuildingExtensions/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# Building Extensions - Overview
3+
4+
These pages will guide you to create your own extension without touching the framework code.
5+
This is possible by dynamically fetching extending content from all assemblies and even enables user extensions.
6+
<br>
7+
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.
8+
9+
<br>
10+
11+
## Covered Topics
12+
<br>
13+
<span style="font-size:1.1em;">
14+
- __ [Custom Nodes](CustomNodes.md)__ - Implementation of custom Nodes
15+
<br><br>
16+
- __ [Custom ConnectionTypes](CustomConnectionTypes.md)__ - Defining custom ConnectinTypes in order to pass custom types with customized visualization
17+
<br><br>
18+
- __ [Adding NodeCanvas Types](AddingNodeCanvasTypes.md)__ - Implementation of custom NodeCanvas Types for customized situations
19+
<br><br>
20+
- __ [Adding Input Controls](AddingInputControls.md)__ - Addition of Input Controls to the dynamic Input System with Attribbutes
21+
<br><br>
22+
- __ [Building an Editor](BuildingAnEditor.md)__ - Building of a custom Editor Window or other user of the Node Editor Framework
23+
<br><br>
24+
- __ [Event & Callbacks](EventsCallbacks.md)__ - Making use of the framework events and callbacks
25+
<br><br>
26+
</span>

Docs/FrameworkOverview.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
# Framework Overview
3+
4+
*(NOTE: This page is WIP)*
5+
6+
This section aims to bring you a decent overview on how the framework is structured, so you can get to modify it quickly.
7+
This does not necessarily include implementation details – code sections that need extra detailing are commented.
8+
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:)
9+
10+
<br>
11+
12+
### `NodeCanvas` and `NodeEditorState`
13+
14+
Those two components essentially make up the save file you can load up into the Editor.
15+
Basically, the canvas stores all the nodes and any additional information directly related to the Canvas.
16+
In contrary, the `EditorState` holds all information on the state, or in other words, on how the Canvas is presented.
17+
This includes zoom and pan values, selected Nodes, the canvasRect, etc. Not all of these values are actually saved with the asset, though.
18+
That structure allows for multiple 'views' on the same Canvas and editing it simultaneously.
19+
20+
<br>
21+
22+
### The `DrawCanvas` function
23+
24+
This function acts very similar to any other GUI control, with a few exceptions, and is responsible for drawing the Canvas.
25+
On the first glance it's just a wrapper for `DrawSubCanvas`, with the exception that it holds the `OverlayGUI` and `NodeGUISkin` code.
26+
`DrawSubCanvas` is used in the future for Nested Canvases, as the name proposes.
27+
28+
First of all, the background texture is splattered across the canvas area based on zoom and pan values.
29+
Then, the function `NodeEditorInputSystem.HandleInputEvents` invokes all dynamic input handlers of the input system to catch all kinds of Input events.
30+
31+
Afterwards the scale area gets initiated with a call to the custom solution `GUIScaleUtility.BeginScale`. <br>
32+
Any GUI code afterwards is getting scaled appropriately.
33+
That means that now all elements that need to be scaled are drawn, including connections, node transitions, connections, bodies and knobs. <br>
34+
Thereafter, the scale area gets closed again with another call to `GUIScaleUtility.EndScale`.
35+
36+
The `NodeEditorInputSystem.HandleLateInputEvents` function then invokes the dynamic input handlers similar to the version before,
37+
with the exception that only those that have to be handled after GUI are invoked.
38+
39+
<br>
40+
41+
#### <u>Framework Part explanations planned</u>
42+
- Dynamic Input System at `NodeEditorInputSystem`
43+
- ConnectionType and Node fetching at `NodeTypes` and `ConnectionTypes`
44+
- Knob Behaviour and Possibilities at `NodeKnob`
45+
- Event/Callback System at `NodeEditorCallbackReceiver`
46+
- Save System at `NodeEditorSaveManager`
47+
- Various Utilities like `GUIScaleUtility`
48+
- Calculation System at `NodeEditor`
49+
- Transitioning System including UnityFunc if they are ready
50+
- Runtime GUI and limitations at `RTEditorGUI` mostly
51+
- Experimental/Conceptional custom NodeCanvases and traversal algorithms
52+

Docs/GettingStarted.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Getting Started
3+
4+
<br>
5+
6+
## Installation
7+
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.
8+
You are then able to open the window at '*Window/Node Editor*' when there are no errors in the project.
9+
10+
11+
<br>
12+
13+
## Examples
14+
15+
### Editor & Canvas
16+
You can start off by opening the Editor Window at '*Window/Node Editor*' and loading an example canvas, such as the *CalculationCanvas*.
17+
Use either the button at the top right or locate it in the project folder and double-click it.
18+
19+
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.
20+
`Control` will snap nodes to the grid and `N` will help you navigate back to the origin or the selected node!
21+
22+
### Example Extensions
23+
For examples on simple extensions, check out all '*Examples/*'-Subbranches on the repository! <br>
24+
One of the currently available examples is the [Texture Composer](https://github.com/Baste-RainGames/Node_Editor/tree/Examples/Texture_Composer),
25+
an example of adding Nodes and ConnectionTypes to extend the framework to simple texture manipulation capabilities. <br>
26+
Another is the [Dialogue System](https://github.com/Baste-RainGames/Node_Editor/tree/Examples/Dialogue-System),
27+
which demonstrates the actual usage of a canvas at runtime to drive a simple dialogue.
28+
29+
### Example Runtime Usage
30+
For more general ideas on how to use the canvas at runtime, you can check out `RTCanvasCalculator`, which is a component that can
31+
calculate and debug the canvas at runtime and also implements some basic but useful helper functions to traverse the canvas at runtime. <br>
32+
It is also possible to show the actual GUI at runtime, as `RuntimeNodeEditor` demonstrates. It works and looks very similar to the editor window
33+
with some limitations due to inaccessibility to the UnityEditor namespace. But aslong as the Nodes use `RTEditorGUI` for available UI controls
34+
and encapsulate all editor-only GUI parts into a preprocessor checks, it is totally possible to give your player access to a Node Editor:)

Docs/License.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Software license
2+
3+
The MIT License (MIT)
4+
5+
Copyright (c) 2015 Baste Nesse Buanes
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.

Docs/extra.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ul.nav.navbar-nav:not(.navbar-right) > li:first-child {
2+
display: none;
3+
}

Docs/img/ConnectionTypes.png

165 KB
Loading

Docs/img/NodeEditorTitle.png

639 KB
Loading

Docs/img/favicon.png

15.4 KB
Loading

0 commit comments

Comments
 (0)