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
  To dynamic generate the connection between paths Canis 4 1,015 08-07-2020, 07:33 PM
Last Post: _Aka_
  Strange differences between editor and build jamesunity 1 491 07-20-2020, 08:49 PM
Last Post: _Aka_
  Gizmos not showing in the editor 2019.3.1 & 3.6 athos_k 5 1,899 06-15-2020, 01:25 PM
Last Post: _Aka_
  Gradually rendering paths Ærilwentar 3 1,082 05-08-2020, 11:03 AM
Last Post: _Aka_

Forum Jump: