Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Referencing Paths in Editor
#1
Hi,

I'm trying to create a class that can reference spline paths in the editor, to dynamically assign to a PathController at runtime. The PathController stores a CGPath, but uses a CGDataReference to actually assign to, it seems like. I'm creating the path with a generator, with Input Path and Rasterize Path nodes.

When I create a CGDataReference member, in the editor I can assign an object that shows up as "Rasterize Path", but that looks like just a reference to the node script itself. How can I access the output of that node in the editor, and assign it to a PathController at runtime?

Thanks,
Johnnemann
Reply
#2
The CGDataReference is a helper to get a module's output data, because output slots aren't serialization safe for Unity, i.e. no ScriptableObjects. The inspector allows you to browse for module's output slots and the CGDataReference stores the module and the name of the output slot and builds the reference at runtime.

Assigning it should be possible at runtime as well, but I'm currently in vacation and can't test it. I'll check that next week and give you a detailed answer then.
Reply
#3
Ok, reviewed it. There were some issues I've corrected for 2.1.1, also improved API of CGDataReference. Changes to several files were needed, so I'll send them to you privately. After you apply the changed files, the following test script will work (used to set the Path from "None" to an existing module at startup):

Code:
using UnityEngine;
using System.Collections;
using FluffyUnderware.Curvy.Generator;
using FluffyUnderware.Curvy.Generator.Modules;
using FluffyUnderware.Curvy.Controllers;


public class test : MonoBehaviour {
   public CurvyGenerator Gen;
   public PathController Ctl;
   // Use this for initialization
IEnumerator  Start () {
       Ctl = GetComponent<PathController>();
       if (Gen)
       {
           while (!Gen.IsInitialized)
               yield return 0;
           var mod = Gen.FindModules<BuildRasterizedPath>()[0];
           Ctl.Path = new CGDataReference(mod, "Path");
       }
}
}
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy Splines Built In Editor Undo causes issues. Lupos 1 9 10-02-2023, 08:52 AM
Last Post: _Aka_
  Can Curve Spline be used for an in game level editor. Lupos 30 71 06-03-2023, 10:58 AM
Last Post: _Aka_
Brick Extending Curvy to make a Hallway editor. JacobSL 5 396 02-13-2023, 09:29 AM
Last Post: _Aka_
  Generator window causes my editor to lag every couple seconds niuage 1 3 03-28-2022, 11:05 AM
Last Post: _Aka_

Forum Jump: