예제 #1
0
    // Initializes Context Card with information from JSON object
    public void InitContextCard(PaintingJSONContainer parsedData, int index)
    {
        // Set title, caption, and description
        string title   = parsedData.pieces[index].pieceName;
        string caption = parsedData.pieces[index].caption;
        string desc    = parsedData.pieces[index].description;

        contextManager.pieceTitle.text     = title;
        contextManager.pieceCaption.text   = caption;
        contextManager.pieceParagraph.text = desc;
    }
예제 #2
0
    private void Start()
    {
        // Gather all 3D and 2D painting pieces, set references
        for (int i = 0; i < gameObject.transform.childCount; i++)
        {
            Transform t = gameObject.transform.GetChild(i);
            if (t.tag == "MaskObject" && !t.name.Contains("[crop]"))
            {
                t.GetComponent <PieceManager>().paintingManager = this;
            }
        }

        // Get the managers
        bioManager     = bioCard.GetComponent <BioCardManager>();
        controlManager = controlCard.GetComponent <ControlCardManager>();

        // Join the JSON path
        string filePath = "JSON/" + paintingName + "/" + paintingName;

        // Load and parse the file
        TextAsset loadedJSON = Resources.Load <TextAsset>(filePath);

        if (loadedJSON != null)
        {
            string     textFromFile = loadedJSON.text;
            JSONObject jsonObject   = new JSONObject(textFromFile);
            parsedData = new PaintingJSONContainer(jsonObject);
        }
        else
        {
            Debug.LogError("Invalid JSON path at " + filePath);
        }

        // Init the UI group
        InitBioCard();
        InitControlCard();

        // Init the context cards of each piece
        int index = 0;

        foreach (Transform t in transform)
        {
            if (!t.name.Contains("[crop]") && t.tag == "MaskObject")
            {
                t.GetComponent <PieceManager>().InitContextCard(parsedData, index);
                index++;
            }
        }
    }