コード例 #1
0
ファイル: GodManager.cs プロジェクト: zsezs/Mafia
    public void textManager(string title, string body, string date)
    {
        this.title.text = title;
        this.body.text  = body;
        this.date.text  = date;

        ScrollSnapRect ssr = godPanel.GetComponentsInChildren <ScrollSnapRect>()[0];
        GameObject     go  = GameObject.Instantiate(textPanel, new Vector3(0, 0, 0), Quaternion.identity);

        go.transform.SetParent(godPanel.transform.GetChild(0).transform.GetChild(0).transform);

        go.transform.localScale = new Vector3(1, 1, 1);

        ssr._pageCount++;
        ssr.SetPagePositions();
    }
コード例 #2
0
ファイル: SubjectScript.cs プロジェクト: tziyanglum/keuze-app
    public void Check(Node unit)
    {
        string sub = unit.Name;

        //Debug.Log(sub);
        title.text = sub;
        title.name = sub;

        foreach (Transform child in container.transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        for (int i = 0; i < unit.Children.Count; i++)
        {
            Node _option;
            _option = unit.Children[i];
            //Debug.Log(_option);

            GameObject   opt = (GameObject)Instantiate(option, transform.position, Quaternion.identity);
            OptionScript os  = opt.GetComponent <OptionScript>();
            os.node = _option;
            //Debug.Log(os.node.Name);

            opt.transform.SetParent(container.transform);
            opt.name = _option.Name;
            opt.GetComponentInChildren <Text>().text = _option.Name;
        }

        ScrollSnapRect ssr = options.GetComponent <ScrollSnapRect>();

        if (ssr._pageCount > 0)
        {
            ssr.LerpToPage(0);
            ssr.SetPagePositions();
        }
    }
コード例 #3
0
    /// <summary>
    /// loads saved user data, if it exists
    /// </summary>
    /// <param name="topic">Chosen topic of the user</param>
    void LoadUserData(Topic topic)
    {
        Debug.Log(folderDataPath);
        if (File.Exists(folderDataPath))
        {
            string data = File.ReadAllText(folderDataPath);
            userData = JsonUtility.FromJson <UserData> (data);

            switch (topic)
            {
            case Topic.ADD:
                Debug.Log("Add");
                DisableAll();
                contents [0].gameObject.SetActive(true);
//				scrollContainers [0].gameObject.SetActive (true);
                scroll            = scrollContainers.gameObject.GetComponent <ScrollSnapRect> ();
                scroll._container = contents [0];
                scroll._scrollRectRect.gameObject.GetComponent <ScrollRect> ().content = contents [0];
                contents [0].localPosition      = origPosition;
                scroll._container.localPosition = origPosition;
                scroll.sceneNames = scroll.GetComponent <SceneNamesReader> ().GetAddSceneNames();
                scroll.SetPageCount(scroll.sceneNames.Length);
                scroll.SetPagePositions();
                scroll.SetCurrentScene(0);
                gameObject.GetComponentInChildren <LevelSelector> ().LoadUserData(topic, userData.currentAdditionSimilarFractionsLevel);
                break;

            case Topic.SUB:
                Debug.Log("Sub");
                DisableAll();
                contents [1].gameObject.SetActive(true);
//				scrollContainers [1].gameObject.SetActive (true);
                scroll            = scrollContainers.gameObject.GetComponent <ScrollSnapRect> ();
                scroll._container = contents [1];
                scroll._scrollRectRect.gameObject.GetComponent <ScrollRect> ().content = contents [1];
                contents[1].localPosition       = origPosition;
                scroll._container.localPosition = origPosition;
                scroll.sceneNames = scroll.GetComponent <SceneNamesReader> ().GetSubSceneNames();
                scroll.SetPageCount(scroll.sceneNames.Length);
                scroll.SetPagePositions();
                scroll.SetCurrentScene(0);
                gameObject.GetComponentInChildren <LevelSelector> ().LoadUserData(topic, userData.currentSubtractionSimilarFractionsLevel);
                break;

            case Topic.MIXED:
                Debug.Log("Mixed");
                DisableAll();
                contents [2].gameObject.SetActive(true);
//				scrollContainers.gameObject.SetActive (true);
                scroll            = scrollContainers.gameObject.GetComponent <ScrollSnapRect> ();
                scroll._container = contents [2];
                scroll._scrollRectRect.gameObject.GetComponent <ScrollRect> ().content = contents [2];
                contents[2].localPosition       = origPosition;
                scroll._container.localPosition = origPosition;
                scroll.sceneNames = scroll.GetComponent <SceneNamesReader> ().GetDisSceneNames();
                scroll.SetPageCount(scroll.sceneNames.Length);
                scroll.SetPagePositions();
                scroll.SetCurrentScene(0);
                gameObject.GetComponentInChildren <LevelSelector> ().LoadUserData(topic, userData.currentDissimilarFractionsLevel);
                break;
            }
            Debug.Log("[SELECT SCENE SCREEN]: Loaded user data");
        }
        else
        {
            Debug.Log("Unable to read the saved user data, file doesn't exist");
            userData = new UserData();
        }
    }