//Example of a custom IEnumerator for kicking off common animations you might not want
    //to wait for during SceneBlock IEnumerators
    IEnumerator ChangeText(PrimerText t, string newString)
    {
        t.ScaleDownToZero();
        yield return(new WaitForSeconds(0.5f));

        t.tmpro.text = newString;
        t.ScaleUpFromZero();
    }
    protected override void Awake()
    {
        base.Awake();
        //Do initialization stuff here
        //e.g., set object scale to zero if they're going to scale in

        text1 = Instantiate(textPrefab, camRig.transform);
        text1.transform.localScale = Vector3.zero;
    }
예제 #3
0
    public void SetUpAxes()
    {
        ////x axis

        //Axis rod
        xAxisRod.transform.localPosition = new Vector3(graph.xAxisOffset, 0f, 0f);
        xAxisRod.transform.localScale    = new Vector3(graph.xAxisLength, xAxisRod.transform.localScale.y, xAxisRod.transform.localScale.z);

        //Axis label
        xAxisLabel = Instantiate(textPrefab, xAxisMasterContainer.transform);
        Vector3 xLabelPos = Vector3.zero;

        if (graph.xAxisLabelPos == "along")
        {
            xLabelPos = new Vector3(graph.xAxisLength / 2 + graph.xAxisOffset, -2 * graph.ticLabelDistanceVertical, 0f);
        }
        else if (graph.xAxisLabelPos == "end")
        {
            xLabelPos = new Vector3(graph.xAxisLength + graph.xAxisOffset + graph.ticLabelDistanceVertical * 1.1f, 0f, 0f);
        }
        xAxisLabel.transform.localPosition = xLabelPos;
        xAxisLabel.tmpro.text      = graph.xAxisLabelString;
        xAxisLabel.tmpro.alignment = TextAlignmentOptions.Midline;

        //Axis arrowheads
        switch (graph.arrows)
        {
        case "both":
            xArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(graph.xAxisLength + graph.xAxisOffset, 0f, 0f), Quaternion.Euler(0f, 90f, 0f), xAxisMasterContainer.transform).transform);
            xArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(graph.xAxisOffset, 0f, 0f), Quaternion.Euler(0f, -90f, 0f), xAxisMasterContainer.transform).transform);
            //Acually, should be localPosition
            xArrows[0].transform.localPosition = xArrows[0].transform.position;
            xArrows[1].transform.localPosition = xArrows[1].transform.position;
            xArrows[0].transform.localRotation = xArrows[0].transform.rotation;
            xArrows[1].transform.localRotation = xArrows[1].transform.rotation;
            break;

        case "positive":
            xArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(graph.xAxisLength + graph.xAxisOffset, 0f, 0f), Quaternion.Euler(0f, 90f, 0f), xAxisMasterContainer.transform).transform);
            xArrows[0].transform.localPosition = xArrows[0].transform.position;
            xArrows[0].transform.localRotation = xArrows[0].transform.rotation;
            break;

        case "neither":
            break;

        default:
            Debug.LogWarning("Graph arrow setting undefined. Defaulting to none.");
            break;
        }
        HandleTicsX();

        if (graph.xHidden)
        {
            xAxisMasterContainer.transform.localScale = new Vector3(0f, 0f, 0f);
        }


        ////y axis

        //Axis rod
        yAxisRod.transform.localPosition = new Vector3(0f, graph.yAxisOffset, 0f);
        yAxisRod.transform.localScale    = new Vector3(yAxisRod.transform.localScale.x, graph.yAxisLength, yAxisRod.transform.localScale.z);

        //Axis label
        yAxisLabel = Instantiate(textPrefab, yAxisMasterContainer.transform);
        Vector3 yLabelPos = Vector3.zero;

        if (graph.yAxisLabelPos == "along")
        {
            yLabelPos = new Vector3(-2 * graph.ticLabelDistanceVertical, graph.yAxisLength / 2 + graph.yAxisOffset, 0f);
        }
        else if (graph.yAxisLabelPos == "end")
        {
            yLabelPos = new Vector3(0f, graph.yAxisLength + graph.yAxisOffset + graph.ticLabelDistanceVertical * 1.1f, 0f);
            yAxisLabel.tmpro.alignment = TextAlignmentOptions.Baseline;
        }
        yAxisLabel.transform.localPosition = yLabelPos;//yAxisLabel.transform.position;
        yAxisLabel.tmpro.text = graph.yAxisLabelString;

        //Axis arrowheads
        switch (graph.arrows)
        {
        case "both":
            yArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(0f, graph.yAxisLength + graph.yAxisOffset, 0f), Quaternion.Euler(-90f, 0f, 0f), yAxisMasterContainer.transform).transform);
            yArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(0f, graph.yAxisOffset, 0f), Quaternion.Euler(90f, 0f, 0f), yAxisMasterContainer.transform).transform);
            //Acually, should be localPosition
            yArrows[0].transform.localPosition = yArrows[0].transform.position;
            yArrows[1].transform.localPosition = yArrows[1].transform.position;
            yArrows[0].transform.localRotation = yArrows[0].transform.rotation;
            yArrows[1].transform.localRotation = yArrows[1].transform.rotation;
            break;

        case "positive":
            yArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(0f, graph.yAxisLength + graph.yAxisOffset, 0f), Quaternion.Euler(-90f, 0f, 0f), yAxisMasterContainer.transform).transform);
            yArrows[0].transform.localPosition = yArrows[0].transform.position;
            yArrows[0].transform.localRotation = yArrows[0].transform.rotation;
            break;

        case "neither":
            break;

        default:
            Debug.LogWarning("Graph arrow setting undefined. Defaulting to none.");
            break;
        }
        HandleTicsY();

        if (graph.yHidden)
        {
            yAxisMasterContainer.transform.localScale = new Vector3(0f, 0f, 0f);
        }


        ////z axis

        //Axis rod
        zAxisRod.transform.localPosition = new Vector3(0f, 0f, graph.zAxisOffset);
        zAxisRod.transform.localScale    = new Vector3(zAxisRod.transform.localScale.x, zAxisRod.transform.localScale.y, graph.zAxisLength);

        //Axis label
        zAxisLabel = Instantiate(textPrefab, zAxisMasterContainer.transform);
        Vector3 zLabelPos = Vector3.zero;

        if (graph.zAxisLabelPos == "along")
        {
            zLabelPos = new Vector3(0f, -2 * graph.ticLabelDistanceVertical, graph.zAxisLength / 2 + graph.zAxisOffset);
        }
        else if (graph.zAxisLabelPos == "end")
        {
            zLabelPos = new Vector3(0f, 0f, graph.zAxisLength + graph.zAxisOffset + graph.ticLabelDistanceVertical * 1.1f);
        }
        zAxisLabel.transform.localPosition = zLabelPos;
        zAxisLabel.tmpro.text      = graph.zAxisLabelString;
        zAxisLabel.tmpro.alignment = TextAlignmentOptions.Midline;

        //Axis arrowheads
        switch (graph.arrows)
        {
        case "both":
            zArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(0f, 0f, graph.zAxisLength + graph.zAxisOffset), Quaternion.Euler(0f, 0f, 0f), zAxisMasterContainer.transform).transform);
            zArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(0f, 0f, graph.zAxisOffset), Quaternion.Euler(0f, -180f, 0f), zAxisMasterContainer.transform).transform);
            zArrows[0].transform.localPosition = zArrows[0].transform.position;
            zArrows[1].transform.localPosition = zArrows[1].transform.position;
            zArrows[0].transform.localRotation = zArrows[0].transform.rotation;
            zArrows[1].transform.localRotation = zArrows[1].transform.rotation;
            break;

        case "positive":
            zArrows.Add(Instantiate(graph.arrowPrefab, new Vector3(0f, 0f, graph.zAxisLength + graph.zAxisOffset), Quaternion.Euler(0f, 0f, 0f), zAxisMasterContainer.transform).transform);
            zArrows[0].transform.localPosition = zArrows[0].transform.position;
            zArrows[0].transform.localRotation = zArrows[0].transform.rotation;
            break;

        case "neither":
            break;

        default:
            Debug.LogWarning("Graph arrow setting undefined. Defaulting to none.");
            break;
        }
        HandleTicsZ();

        //We use right-handed systems around these parts
        if (graph.rightHanded)
        {
            zAxisMasterContainer.SetIntrinsicScale(new Vector3(1f, 1f, -1f));
            zAxisMasterContainer.transform.localScale = zAxisMasterContainer.GetIntrinsicScale();
        }

        if (graph.zHidden)
        {
            zAxisMasterContainer.transform.localScale = new Vector3(0f, 0f, 0f);
        }
    }