1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-21 01:36:03 +08:00

Cleaned up

This commit is contained in:
Thor Brigsted 2017-09-20 20:25:21 +02:00
parent f9152bf891
commit d3f0d96954
9 changed files with 27 additions and 122 deletions

View File

@ -1,9 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BaseNode : Node {
public class BaseNode : Node {
public string asdf;
protected override void Init() {
inputs = new NodePort[2];

View File

@ -7,6 +7,22 @@ using System;
/// <summary> Contains GUI methods </summary>
public partial class NodeEditorWindow {
private void OnGUI() {
Event e = Event.current;
Matrix4x4 m = GUI.matrix;
Controls();
if (e.type != EventType.MouseMove && e.type != EventType.MouseDrag) {
DrawGrid(position, zoom, panOffset);
DrawNodes();
DrawConnections();
DrawDraggedConnection();
DrawToolbar();
}
GUI.matrix = m;
}
public static void DrawConnection(Vector2 from, Vector2 to, Color col) {
Handles.DrawBezier(from, to, from, to, col, new Texture2D(2, 2), 2);
}

View File

@ -23,6 +23,7 @@ public partial class NodeEditorWindow {
GUIStyle outputInt, outputString, outputFloat, outputObject, outputTexture, outputColor;
public Styles() {
inputObject = new GUIStyle((GUIStyle)"flow shader in 0");
inputString = new GUIStyle((GUIStyle)"flow shader in 1");
inputInt = new GUIStyle((GUIStyle)"flow shader in 2");
@ -45,6 +46,7 @@ public partial class NodeEditorWindow {
}
public GUIStyle GetInputStyle(Type type) {
if (type == typeof(int)) return inputInt;
else if (type == typeof(string)) return inputString;
else if (type == typeof(Texture2D)) return inputTexture;

View File

@ -26,20 +26,6 @@ public partial class NodeEditorWindow : EditorWindow {
w.Show();
}
private void OnGUI() {
Event e = Event.current;
Matrix4x4 m = GUI.matrix;
Controls();
DrawGrid(position, zoom, panOffset);
DrawNodes();
DrawConnections();
DrawDraggedConnection();
if (e.type == EventType.Repaint || e.type == EventType.Layout) DrawToolbar();
GUI.matrix = m;
}
public void DrawConnections() {
foreach(Node node in graph.nodes) {
for (int i = 0; i < node.OutputCount; i++) {
@ -95,8 +81,7 @@ public partial class NodeEditorWindow : EditorWindow {
GUILayout.EndHorizontal();
GUILayout.Label("More stuff");
EditorGUILayout.Toggle("aDF",false);
// GUI
GUILayout.EndArea();
@ -113,9 +98,6 @@ public partial class NodeEditorWindow : EditorWindow {
private void DraggableWindow(int windowID) {
GUI.DragWindow();
if (GUILayout.Button("ASDF")) Debug.Log("ASDF");
if (GUI.Button(new Rect(20,20,200,200),"ASDF")) Debug.Log("ASDF");
}
public Vector2 WindowToGridPosition(Vector2 windowPosition) {

View File

@ -41,11 +41,11 @@ public abstract class Node {
return outputs[portId];
}
public NodePort CreateNodeInput(string name, Type type, bool enabled = true) {
return new NodePort(name, type, this, enabled, NodePort.IO.Input);
public NodePort CreateNodeInput(string name, Type type) {
return new NodePort(name, type, this, NodePort.IO.Input);
}
public NodePort CreateNodeOutput(string name, Type type, bool enabled = true) {
return new NodePort(name, type, this, enabled, NodePort.IO.Output);
public NodePort CreateNodeOutput(string name, Type type) {
return new NodePort(name, type, this, NodePort.IO.Output);
}
public void ClearConnections() {

View File

@ -27,12 +27,11 @@ public class NodePort {
private List<NodePort> connections = new List<NodePort>();
[SerializeField] private string _name;
[SerializeField] private bool _enabled;
[SerializeField] private bool _enabled = true;
[SerializeField] private IO _direction;
public NodePort(string name, Type type, Node node, bool enabled, IO direction) {
public NodePort(string name, Type type, Node node, IO direction) {
_name = name;
_enabled = enabled;
_type = type;
this.node = node;
_direction = direction;

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 003638a12027abc46ba0fa1719d11246
folderAsset: yes
timeCreated: 1505424851
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 B

View File

@ -1,82 +0,0 @@
fileFormatVersion: 2
guid: 00e76aa739b5f474fabc717677698eef
timeCreated: 1505424840
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant: