Ejemplo n.º 1
0
    // This gets all the control positions from the original rageSpline (which we are editing) and moves our GUI accordingly
    public void refreshEditorGUI()
    {
        for (int index = 0; index < rageSpline.GetPointCount(); index++)
        {
            // We are just moving the GameObject transform. No need to access the API.
            controlPoints[index].transform.position    = rageSpline.GetPositionWorldSpace(index) + new Vector3(0f, 0f, -1f);
            inControlPoints[index].transform.position  = rageSpline.GetInControlPositionWorldSpace(index) + new Vector3(0f, 0f, -1f);
            outControlPoints[index].transform.position = rageSpline.GetOutControlPositionWorldSpace(index) + new Vector3(0f, 0f, -1f);

            // Put the object transform center where the control point is
            handleLines[index].transform.position = rageSpline.GetPositionWorldSpace(index) + new Vector3(0f, 0f, -0.5f);

            // Set both ends of the line where the underlying in/out ctrlpoint handles are
            handleLines[index].SetPointWorldSpace(0, rageSpline.GetInControlPositionWorldSpace(index));
            handleLines[index].SetPointWorldSpace(1, rageSpline.GetOutControlPositionWorldSpace(index));

            // Handles pointing to the middle to make a straight line
            handleLines[index].SetOutControlPositionPointSpace(0, (rageSpline.GetPosition(index) - rageSpline.GetOutControlPosition(index)) * 0.25f);
            handleLines[index].SetOutControlPositionPointSpace(1, (rageSpline.GetInControlPosition(index) - rageSpline.GetPosition(index)) * 0.25f);

            // Since we modified the spline, we need to refresh the mesh
            handleLines[index].RefreshMesh(false, true, false);
        }
    }