Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

How to set Range in a component?

Discussion in 'Project Tiny' started by Rupture13, Mar 5, 2019.

  1. Rupture13

    Rupture13

    Joined:
    Apr 12, 2016
    Posts:
    131
    So I'm working on a ParticleEmitter, and want to edit some of the properties in code.

    However, the component fields are of type "Range" (which is not the same as "ut.Math.Range"),
    which seems to be some JavaScript struct working with nodes and offsets.
    These Ranges have a "start" and an "end" field in the inspector, which serve as a minimum and maximum between which the game randomly picks a value. I would like to set these fields,
    but I don't know how.

    The only methods to edit the start and end fields in code take some sort of node and offset parameters, which I have no idea how to use so that it translates to my desired start and end values.

    The source interface of Range has these methods:
    Code (CSharp):
    1.     setEnd(node: Node, offset: number): void;
    2.     setEndAfter(node: Node): void;
    3.     setEndBefore(node: Node): void;
    4.     setStart(node: Node, offset: number): void;
    5.     setStartAfter(node: Node): void;
    6.     setStartBefore(node: Node): void;
    I also have no idea why the fields are stored in such a weird way when for example a Vector2 would've worked fine.

    Anyone know how to set these values (or how to use the methods with node and offset)?