public override void Modify(CCText text)
    {
        char
            b             = rangeBeginSymbol[0],
            e             = rangeEndSymbol[0];
        Color normalColor = text.Color;

        Color[] colors = text.colors;
        for (int i = 0, v = 0, l = text.Length; i < l; i++)
        {
            char c = text[i];
            if (c <= ' ')
            {
                continue;
            }
            if (b <= c && c <= e)
            {
                colors[v]     = color;
                colors[v + 1] = color;
                colors[v + 2] = color;
                colors[v + 3] = color;
            }
            else
            {
                colors[v]     = normalColor;
                colors[v + 1] = normalColor;
                colors[v + 2] = normalColor;
                colors[v + 3] = normalColor;
            }
            v += 4;
        }
        text.mesh.colors = colors;
    }
Ejemplo n.º 2
0
    public override void Modify(CCText text)
    {
        float
            offset = text.minBounds.y,
            scale  = 1f / (text.maxBounds.y - offset);

        Vector3[] vertices = text.vertices;
        Color[]   colors   = text.colors;
        for (int i = 0, v = 0, l = text.Length; i < l; i++)
        {
            char c = text[i];
            if (c <= ' ')
            {
                continue;
            }
            Color
                top    = Color.Lerp(bottomColor, topColor, (vertices[v].y - offset) * scale),
                bottom = Color.Lerp(bottomColor, topColor, (vertices[v + 2].y - offset) * scale);
            colors[v]     = top;
            colors[v + 1] = top;
            colors[v + 2] = bottom;
            colors[v + 3] = bottom;
            v            += 4;
        }
        text.mesh.colors = colors;
    }
    public void OnSceneGUI()
    {
        CCText box = (CCText)target;

        if (!box.enabled)
        {
            return;
        }

        Vector3
            min     = box.minBounds,
            max     = box.maxBounds;
        Transform t = box.transform;

        if (min.z == max.z)
        {
            // draw a white box to show mesh bounds and a yellow box to show caret bounds
            CCEditorUtility.DrawWireRectangle(min, max, t);
            Handles.color = Color.yellow;
            CCEditorUtility.DrawWireRectangle(box.CaretMinBounds, box.CaretMaxBounds, t);
        }
        else
        {
            CCEditorUtility.DrawWireCube(min, max, t);
        }
    }
    private void RevolveX(CCText text)
    {
        Vector3[] vertices = text.vertices;
        Vector3
            minBounds = notMinimum,
            maxBounds = notMaximum;
        float
            r   = text.Offset.z - minorRadius,
            y2u = majorRadius == 0f ? 0f : -1f / majorRadius,
            x2v = r == 0f ? 0f : 1f / r;

        for (int i = 0, v = 0, l = text.Length; i < l; i++)
        {
            if (text[i] <= ' ')
            {
                continue;
            }
            for (int lv = v + 4; v < lv; v++)
            {
                Vector3 vertex = vertices[v];
                float
                    U = vertex.y * y2u,
                    V = vertex.x * x2v,
                    R = (r * Mathf.Cos(V) - majorRadius);
                vertex.z    = R * Mathf.Cos(U);
                vertex.y    = R * Mathf.Sin(U);
                vertex.x    = r * Mathf.Sin(V);
                vertices[v] = vertex;

                if (vertex.x > maxBounds.x)
                {
                    maxBounds.x = vertex.x;
                }
                if (vertex.x < minBounds.x)
                {
                    minBounds.x = vertex.x;
                }
                if (vertex.y > maxBounds.y)
                {
                    maxBounds.y = vertex.y;
                }
                if (vertex.y < minBounds.y)
                {
                    minBounds.y = vertex.y;
                }
                if (vertex.z > maxBounds.z)
                {
                    maxBounds.z = vertex.z;
                }
                if (vertex.z < minBounds.z)
                {
                    minBounds.z = vertex.z;
                }
            }
        }
        text.minBounds = minBounds;
        text.maxBounds = maxBounds;
    }
Ejemplo n.º 5
0
    public void TypewriterSay(CCText targetText, string s, float extraTime = 1f)
    {
        float timeMod = 1;

        ResetTypewriter(s);
        currentText = targetText;
        t           = s.Length * timeMod * charInterval + 6 + extraTime;
        showing     = true;
    }
    static void CreateTextBox()
    {
        CCFont font   = Selection.activeObject as CCFont;
        CCText newBox = CCEditorUtility.CreateGameObjectWithComponent <CCText>("New Text Box");

        if (font != null)
        {
            // set its font to the currently selected font
            newBox.Font = font;
        }
    }
 public override void Modify(CCText text)
 {
     if (revolveMode == RevolveMode.X)
     {
         RevolveX(text);
     }
     else
     {
         RevolveY(text);
     }
 }
 public override void Modify(CCText text)
 {
     if (wrapMode == WrapMode.X)
     {
         WrapX(text);
     }
     else
     {
         WrapY(text);
     }
 }
Ejemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (t < 1)
     {
         t += UnityEngine.Time.deltaTime / 5;
         gameObject.transform.localScale = new Vector3(1, 1, 1) * (t * 2 + 1);
         Vector3 pos = gameObject.transform.localPosition;
         pos.y -= UnityEngine.Time.deltaTime * -0.6f;
         gameObject.transform.localPosition = pos;
         CCText text = gameObject.GetComponentInChildren <CCText>();
         Color  rgba = text.Color;
         rgba.a     = 1 - t;
         text.Color = rgba;
     }
 }
Ejemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        cct = GetComponent <CCText>();
//		if (rainbow){
//			myColors = new Color[7];
//			myColors[0]=Color.red;
//			myColors[1]=new Color(1,3,0,1); // orange?
//			myColors[2]=Color.yellow;
//			myColors[3]=Color.green;
//			myColors[4]=Color.blue;
//			myColors[5]=Color.cyan;
//			myColors[6]=new Color(1,0,1,1);
//
//
//		}
    }
    public override void Modify(CCText text)
    {
        char
            b = beginSymbol[0],
            e = endSymbol[0];
        Color currentColor = text.Color;

        Color[] colors = text.colors;
        for (int i = 0, v = 0, l = text.Length; i < l; i++)
        {
            char c = text[i];
            if (c <= ' ')
            {
                continue;
            }
            if (c == b)
            {
                colors[v]     = currentColor;
                colors[v + 1] = currentColor;
                colors[v + 2] = currentColor;
                colors[v + 3] = currentColor;
                currentColor  = color;
            }
            else if (c == e)
            {
                currentColor  = text.Color;
                colors[v]     = currentColor;
                colors[v + 1] = currentColor;
                colors[v + 2] = currentColor;
                colors[v + 3] = currentColor;
            }
            else
            {
                colors[v]     = currentColor;
                colors[v + 1] = currentColor;
                colors[v + 2] = currentColor;
                colors[v + 3] = currentColor;
            }
            v += 4;
        }
        text.mesh.colors = colors;
    }
    public override void OnInspectorGUI()
    {
        serializedBox.Update();

        EditorGUILayout.PropertyField(color);

        Object oldFont = font.objectReferenceValue;

        EditorGUILayout.PropertyField(font);
        if (font.objectReferenceValue != null && oldFont != font.objectReferenceValue && !((CCFont)font.objectReferenceValue).IsValid)
        {
            font.objectReferenceValue = oldFont;
            Debug.LogWarning("CCText refused to accept an invalid CCFont. Please import font data first.");
        }

        EditorGUILayout.PropertyField(modifier);
        EditorGUILayout.PropertyField(alignment);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Anchor");
        EditorGUILayout.PropertyField(horizontalAnchor, anchorContent, anchorWidth);
        EditorGUILayout.PropertyField(verticalAnchor, anchorContent, anchorWidth);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.PropertyField(bounding);
        EditorGUILayout.PropertyField(width);
        EditorGUILayout.PropertyField(chunkSize);
        EditorGUILayout.PropertyField(lineHeight);
        EditorGUILayout.PropertyField(tabSize);
        EditorGUILayout.PropertyField(offset);

        if (!serializedBox.isEditingMultipleObjects)
        {
            if (textFieldStyle == null)
            {
                EditorGUIUtility.LookLikeControls();
                textFieldStyle          = new GUIStyle(EditorStyles.textField);
                textFieldStyle.wordWrap = true;
            }
            CCText box = (CCText)target;
            GUILayout.Label("Text", text.prefabOverride ? EditorStyles.boldLabel : EditorStyles.label);
            string newText = EditorGUILayout.TextArea(text.stringValue, textFieldStyle, GUILayout.Height(81f));
            if (!newText.Equals(text.stringValue))
            {
                text.stringValue = newText;
            }
            if (box.enabled)
            {
                GUILayout.Label(" using " + box.UsedSpriteCount + " of " + box.SpriteCount + " sprites", EditorStyles.miniLabel);
            }
        }

        if (serializedBox.ApplyModifiedProperties() || CCEditorUtility.UndoRedoEventHappened)
        {
            foreach (CCText t in targets)
            {
                if (PrefabUtility.GetPrefabType(t) != PrefabType.Prefab)
                {
                    if (t.LineHeight < 0)
                    {
                        t.LineHeight = 0;
                    }
                    if (t.TabSize < 0.001f)
                    {
                        t.TabSize = 0.001f;
                    }
                    if (t.Width < 0)
                    {
                        t.Width = 0;
                    }
                    t.ResetColors();
                    t.UpdateText();
                }
            }
        }
    }
 /// <summary>
 /// Modify a CCText.
 /// </summary>
 /// <param name="text">
 /// A <see cref="CCText"/>.
 /// </param>
 public abstract void Modify(CCText text);
    private void WrapX(CCText text)
    {
        Vector3[] vertices = text.vertices;
        Vector3
            minBounds = notMinimum,
            maxBounds = notMaximum;
        float
            r   = text.Offset.z - radius,
            y2r = r == 0f ? 0f : 1f / r;

        for (int i = 0, v = 0, l = text.Length; i < l; i++)
        {
            if (text[i] <= ' ')
            {
                continue;
            }
            // vertex 0
            Vector3 vertex = vertices[v];
            float   rad    = vertex.y * y2r;
            vertex.y    = Mathf.Sin(rad) * r;
            vertex.z    = Mathf.Cos(rad) * r;
            vertices[v] = vertex;

            if (vertex.x > maxBounds.x)
            {
                maxBounds.x = vertex.x;
            }
            if (vertex.x < minBounds.x)
            {
                minBounds.x = vertex.x;
            }
            if (vertex.y > maxBounds.y)
            {
                maxBounds.y = vertex.y;
            }
            if (vertex.y < minBounds.y)
            {
                minBounds.y = vertex.y;
            }
            if (vertex.z > maxBounds.z)
            {
                maxBounds.z = vertex.z;
            }
            if (vertex.z < minBounds.z)
            {
                minBounds.z = vertex.z;
            }

            // vertex 1
            vertices[v + 1].y = vertex.y;
            vertices[v + 1].z = vertex.z;

            // vertex 2
            vertex          = vertices[v + 2];
            rad             = vertex.y * y2r;
            vertex.y        = Mathf.Sin(rad) * r;
            vertex.z        = Mathf.Cos(rad) * r;
            vertices[v + 2] = vertex;

            if (vertex.x > maxBounds.x)
            {
                maxBounds.x = vertex.x;
            }
            if (vertex.x < minBounds.x)
            {
                minBounds.x = vertex.x;
            }
            if (vertex.y > maxBounds.y)
            {
                maxBounds.y = vertex.y;
            }
            if (vertex.y < minBounds.y)
            {
                minBounds.y = vertex.y;
            }
            if (vertex.z > maxBounds.z)
            {
                maxBounds.z = vertex.z;
            }
            if (vertex.z < minBounds.z)
            {
                minBounds.z = vertex.z;
            }

            // vertex 3
            vertices[v + 3].y = vertex.y;
            vertices[v + 3].z = vertex.z;
            v += 4;
        }
        text.minBounds = minBounds;
        text.maxBounds = maxBounds;
    }