コード例 #1
0
    private void SetupControlTranslateArrow(GameObject controlPoint)
    {
        //get the current curvePoint
        BGCurvePointGO curvePoint = controlPoint.GetComponent <BGCurvePointGO>();

        //spawn empty gameobject for arrow to move
        GameObject controlObj = new GameObject();

        //sets gos position
        controlObj.transform.position = curvePoint.ControlFirstWorld;
        controlObj.transform.SetParent(controlPoint.transform);
        //add setcurvecontrol... script to new gameobject
        SetCurveControlToGizmoPosition curveControl = controlObj.AddComponent <SetCurveControlToGizmoPosition>();

        //set new setcuvecontrol... curve point to proper curve point so it can move it
//        print(curvePoint);
        curveControl.curvePoint = curvePoint;
//        print(curveControl.curvePoint);
        //set the control vector to the new game object's position(probs in curvecontroltogizmo script)

        //spawn arrow gizmo
        GameObject newArrow = Instantiate(translateArrowPrefab);

        objsToDisable.Add(newArrow);
        //parent arrow to controlPoint
        newArrow.transform.SetParent(controlPoint.transform);
        //get the gizmotranslate componenet from the arrow
        GizmoTranslateScript gizmoTranslate = newArrow.GetComponent <GizmoTranslateScript>();

        //set arrows position to curvePoint location
        newArrow.transform.position = curvePoint.ControlFirstWorld;
        //set arrows translateTarget to the new gameobject
        gizmoTranslate.translateTarget = controlObj;

        //set the gizmo cameras on the parts for the arrow
        GizmoClickDetection[] detectors = newArrow.GetComponentsInChildren <GizmoClickDetection>();
        foreach (var detector in detectors)
        {
            detector.gizmoCamera = gizmoCamera;
        }

        curveControl.gizmoTranslate = gizmoTranslate;
    }
コード例 #2
0
    private void SetupTranslateArrow(GameObject newCurve)
    {
        GameObject newPoint = newCurve.transform.GetChild(newCurve.transform.childCount - 1).gameObject;

        GameObject arrow = Instantiate(translateArrowPrefab);

        objsToDisable.Add(arrow);
        GizmoTranslateScript arrowTranslate = arrow.GetComponent <GizmoTranslateScript>();

        arrowTranslate.translateTarget    = newPoint;
        arrowTranslate.transform.position = newPoint.transform.position;

        GizmoClickDetection[] detectors = arrow.GetComponentsInChildren <GizmoClickDetection>();
        foreach (var detector in detectors)
        {
            detector.gizmoCamera = gizmoCamera;
        }

        arrow.transform.SetParent(newCurve.transform.GetChild(newCurve.transform.childCount - 1));
    }