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

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?

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.
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):

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");

Possibly Related Threads…
Thread Author Replies Views Last Post
Brick Extending Curvy to make a Hallway editor. JacobSL 5 395 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_
  To dynamic generate the connection between paths Canis 4 2,156 08-07-2020, 07:33 PM
Last Post: _Aka_
  Strange differences between editor and build jamesunity 1 1,079 07-20-2020, 08:49 PM
Last Post: _Aka_

Forum Jump: