Seneral / Node_Editor_Framework

A flexible and modular Node Editor Framework for creating node based displays and editors in Unity
https://nodeeditor.seneral.dev
MIT License
2.01k stars 415 forks source link

Add optional, automatic resizing to nodes #120

Closed JoshAshby closed 7 years ago

JoshAshby commented 7 years ago

As per issue #39 this gives nodes the ability to resize according to the GUILayout content inside of them. I made this optional and defaulted it to being off, since it'll probably break the size of old nodes.

To use, override Vector2 MinSize and bool Resizable and only set the rect.position:

        public override Vector2 MinSize { get { return new Vector2(200, 10); } }
        public override bool Resizable { get { return true; } }

        public override string GetID { get { return "resizingNode"; } }

        public override Node Create(Vector2 pos)
        {
            ResizingNode node = CreateInstance<ResizingNode>();

            node.rect.position = pos;
            node.name = "Resizing Node";

            return node;
        }

Seneral commented 7 years ago

Thank you! Really cool:) Turning it off by default was good, this would overwrite the width forever as size is only set in Create so far. But I have plans to make everything in Create set as parameters which would make it easily possible to turn it on by default...