コード例 #1
0
    void Start()
    {
        content = new AnnotationContent();

        images = new List <Texture2D>();

        //this changes parsedText and imgPaths
        ParseAnnotation.ParseAnnotationText(text, content);

        if (includeImages)
        {
            foreach (string path in content.imagePaths)
            {
                //grabbing byte data from file so we can convert it into a texture
                try {
                    byte[]    fileData = File.ReadAllBytes(imagePath + path);
                    Texture2D img      = new Texture2D(2, 2);
                    img.LoadImage(fileData);
                    images.Add(img);
                } catch (Exception e)
                {
                    Debug.Log(e);
                    images.Add(null);
                }
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Takes a string and parses text so that textOut gets populated by strings, separated by image paths that are stored in imgOut
    /// </summary>
    /// <param name="text"></param>
    /// <param name="textOut"></param>
    /// <param name="imgOut"></param>
    public static void ParseAnnotationText(string text, AnnotationContent content)
    {
        string[] splitText = Regex.Split(text, IMAGE_TEXT_FULL);
        content.parsedText.AddRange(splitText);

        MatchCollection imgCollection = Regex.Matches(text, IMAGE_TEXT_FULL);

        string replacement = "";
        Regex  rgx         = new Regex(IMAGE_TEXT_SPLIT);

        foreach (Match i in imgCollection)
        {
            string x = rgx.Replace(i.ToString(), replacement);
            content.imagePaths.Add(x);
        }
    }
コード例 #3
0
    // Add the newest entry in the in-range area annotations to the UI.
    // <param name="a">Annotation to display</param>
    private void DisplayFullAnnotation(Annotation a)
    {
        AnnotationContent content = a.content;
        List <Texture2D>  images  = a.images;

        for (int i = 0; i < Math.Max(images.Count, content.parsedText.Count); i++)
        {
            if (i < content.parsedText.Count && content.parsedText [i] != "")
            {
                AddText(content.parsedText [i]);
            }

            if (i < images.Count)
            {
                AddImage(images [i]);
            }
        }
    }
コード例 #4
0
    // Display the detailed content of the journal entry.
    // <param name="e">Journal entry to display</param>
    private void DisplayInfo(JournalEntry e)
    {
        AnnotationContent content = e.content;
        List <Texture2D>  images  = e.images;

        for (int i = 0; i < Math.Max(images.Count, content.parsedText.Count); i++)
        {
            if (i < content.parsedText.Count && content.parsedText [i] != "")
            {
                AddText(content.parsedText [i]);
            }

            if (i < images.Count)
            {
                AddImage(images [i]);
            }
        }
    }
コード例 #5
0
    void Start()
    {
        content = new AnnotationContent();

        scrollPosition = new Vector2(0, 0);

        rectangle = new Rect(BOX_X, BOX_Y, BOX_WIDTH, BOX_HEIGHT);

        //setting up style for text
        fullStyle                  = new GUIStyle();
        fullStyle.wordWrap         = true;
        fullStyle.richText         = true;
        fullStyle.normal.textColor = Color.white;
        fullStyle.padding.bottom   = 15;
        fullStyle.padding.top      = 15;

        images = new List <Texture2D>();

        //this changes parsedText and imgPaths
        ParseAnnotation.ParseAnnotationText(text, content);

        if (includeImages)
        {
            foreach (string path in content.imagePaths)
            {
                //grabbing byte data from file so we can convert it into a texture
                try {
                    byte[]    fileData = File.ReadAllBytes(imagePath + path);
                    Texture2D img      = new Texture2D(2, 2);
                    img.LoadImage(fileData);
                    images.Add(img);
                } catch (Exception e)
                {
                    Debug.Log(e);
                    images.Add(null);
                }
            }
        }
    }