Carpet & Scroll

Warning

This page is still being written

This will show you how to roll up a mesh and then use the Scroll.cs helper script to make a dynamic scroll system.

Rolling up a carpet

Making a Scroll

This is a simple script that you can add to a gameobject that already has two bends applied that have been setup to roll the mesh from each end as shown above, the pos param will then control what part of the scroll is unrolled with the gap value giving the distance between the two ends.

Params

Pos

How far along the scroll we want to display, 0 is fully rolled up unread scroll, 100 is fully rolled up read scroll.

Gap

The distance between the two rolls.

Scroll.cs

using UnityEngine;

[ExecuteInEditMode]
public class Scroll : MonoBehaviour
{
    public float pos = 0.0f;
    public float gap = 0.5f;

    public Vector3  wpos;

    MegaBend[]  bends;

    void Update()
    {
        if ( bends == null )
        {
            bends = GetComponents<MegaBend>();
        }

        bends[1].gizmoPos.x = pos - gap;
        bends[0].gizmoPos.x = pos + gap;

        Vector3 p = transform.position;

        p.x = wpos.x + pos;
        transform.position = p;
    }
}

You must be logged in to post a comment.