コード例 #1
0
ファイル: CutSceneUnit.cs プロジェクト: JSungMin/MomentFlow05
    public void AddCurvePoint()
    {
        tracks[nowTrackIndex].size += 1;

        GameObject newPosition = new GameObject((tracks[nowTrackIndex].positionItemList.Count + 1).ToString());

        newPosition.transform.parent   = tracks[nowTrackIndex].transform;
        newPosition.transform.position = tracks[nowTrackIndex].positionItemList[tracks[nowTrackIndex].positionItemList.Count - 1].transform.position + Vector3.right * 2;
        newPosition.AddComponent <SnapOnGrid> ();

        var hierarchy = newPosition.AddComponent <HierarchySystem> ();

        hierarchy.SetParent(tracks[nowTrackIndex].transform, this);
        hierarchy.index = tracks[nowTrackIndex].positionItemList.Count;

        var newItem = new PositionItem(tracks[nowTrackIndex].positionItemList.Count, newPosition.transform);

        tracks[nowTrackIndex].positionItemList.Add(newItem);
        var spline = new BeizerSpline();

        if (tracks[nowTrackIndex].positionItemList [tracks[nowTrackIndex].positionItemList.Count - 2].transform.GetComponent <BeizerSpline> () == null)
        {
            spline = tracks[nowTrackIndex].positionItemList [tracks[nowTrackIndex].positionItemList.Count - 2].transform.gameObject.AddComponent <BeizerSpline> ();
            spline.SetControlPoint(1, (tracks[nowTrackIndex].positionItemList [tracks[nowTrackIndex].positionItemList.Count - 1].transform.position + newPosition.transform.position) * 0.5f);
        }
        else
        {
            Debug.LogError("Already have Curve");
        }
    }
コード例 #2
0
    private void OnSceneGUI()
    {
                #if UNITY_EDITOR
        spline = target as BeizerSpline;
        if (spline != null)
        {
            if (spline.GetComponentInParent <PositionPool>().positionItemList.Count - 1 < spline.GetComponent <HierarchySystem>().index + 1)
            {
                return;
            }
        }
        else
        {
            return;
        }

        handleTransform = spline.transform;
        handleRotation  = Tools.pivotRotation == PivotRotation.Local ?
                          handleTransform.rotation : Quaternion.identity;

        Vector3 p0 = spline.transform.position;
        spline.SetControlPoint(0, p0);

        Vector3 p1 = ShowPoint(1);

        Vector3 p2 = spline.GetComponentInParent <PositionPool>().positionItemList [spline.GetComponent <HierarchySystem> ().index + 1].transform.position;
        spline.SetControlPoint(2, p2);

        Handles.color = Color.gray;
        Handles.DrawLine(p0, p1);
        Handles.DrawLine(p1, p2);

        Handles.color = Color.white;
        Vector3 lineStart = spline.GetPoint(0f);
        for (int i = 1; i <= lineSteps; i++)
        {
            Vector3 lineEnd = spline.GetPoint(i / (float)lineSteps);
            Handles.DrawLine(lineStart, lineEnd);
            lineStart = lineEnd;
        }
                #endif
    }
コード例 #3
0
    private Vector3 ShowPoint(int index)
    {
        Vector3 point = (spline.GetControlPoint(index));
        float   size  = HandleUtility.GetHandleSize(point);

        if (Handles.Button(point, handleRotation, size * handleSize, pickSize, Handles.DotCap))
        {
            selectedIndex = index;
            Repaint();
        }
        if (selectedIndex == index && index != 0 && index != 2)
        {
            EditorGUI.BeginChangeCheck();
            point = Handles.DoPositionHandle(point, handleRotation);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(spline, "Move Point");
                EditorUtility.SetDirty(spline);
                spline.SetControlPoint(index, (point));
            }
        }
        return(point);
    }