Пример #1
0
    // Use this for initialization
    void Awake()
    {
        // Add "TSS Core" component
        TSSCore core = this.gameObject.AddComponent <TSSCore>();

        // Clone state object and additing clone to core as new state
        for (int i = 0; i < stateCount; i++)
        {
            // Clone state or use first
            TSSItem newStateObject = i == 0 ?
                                     stateObject :
                                     Instantiate(stateObject.gameObject, this.transform).GetComponent <TSSItem>();

            // Mark state text by index
            Text stateText = newStateObject.GetComponentInChildren <Text>();
            stateText.text = (i + 1).ToString();

            // Add state and selecting key
            TSSState stateState = core.AddState(newStateObject, (i + 1).ToString());
            stateState.AddSelectionKey((KeyCode)((int)KeyCode.Alpha1 + i));
        }

        // Set first core state as default. Default state will be selected and activated on start.
        // You can use any of syntax:
        // core.SetDefaultState(core.GetState("0"));
        // core.SetDefaultState("0");
        // core.SetDefaultState(core[0]);
        core[0].SetAsDefault();

        // Allow core events
        core.useEvents = true;

        // Update navigation buttons interactable by core events
        core.OnStateSelected.AddListener(state =>
        {
            prevBtn.interactable = !state.isFirst;
            nextBrn.interactable = !state.isLast;
        });

        // Attach core selecting method to buttons
        nextBrn.onClick.AddListener(core.SelectNextState);
        prevBtn.onClick.AddListener(core.SelectPreviousState);

        // Select core state
        // You can use any of syntax:
        // core.SelectState(core.GetState(0).ToString()));
        // core.SelectState("0");
        // core.GetState((currentStateID + 1).ToString()).Select();
        core[0].Select();
    }
Пример #2
0
    public void checkInfoPrep(GameObject infoRightPrep, GameObject groupSlideLeft, int i)
    {
        Text lameLeftGroup = groupSlideLeft.GetComponentInChildren <Text>();

        lameLeftGroup.text = _linkPrep[i - 1].NamePrep;

        buttonInfoPrep infoPrep = groupSlideLeft.GetComponent <buttonInfoPrep>();

        if (infoPrep == null)
        {
            infoPrep = groupSlideLeft.AddComponent <buttonInfoPrep>();
        }
        infoPrep.SetInfo(i, _coreInfo);
        _coreInfo.AddState(infoRightPrep.GetComponent <TSSItem>(), (i).ToString());
        _coreInfo[i - 1].AddItem(groupSlideLeft.GetComponent <TSSItem>());
        checkItemPrep(infoRightPrep.transform.GetChild(1).transform.GetChild(0).gameObject, i - 1);

        setNames(infoRightPrep.transform.GetChild(0).gameObject, i - 1);
    }
Пример #3
0
 private void AddState(bool isLast = false)
 {
     Undo.RecordObject(core, "[TSS Core] new state");
     foldOutStates.target        = true;
     core.AddState(null).editing = true;
 }
Пример #4
0
    IEnumerator LoadContent()
    {
        GameObject emptyGO      = new GameObject();
        string     pathToFolder = Path.Combine(Application.streamingAssetsPath, _pathFromStreamingFolder);

        string[] dirs = Directory.GetDirectories(pathToFolder);

        string pathToFile = Path.Combine(dirs[0], "size.txt");

        if (!File.Exists(pathToFile))
        {
            Debug.LogError("Size file not found!!!");
        }

        string[] vextorSize = File.ReadAllLines(pathToFile);
        float.TryParse(vextorSize[0], out _sizeImage.x);
        float.TryParse(vextorSize[1], out _sizeImage.y);
        int.TryParse(vextorSize[2], out _countArrayWidth);
        int.TryParse(vextorSize[3], out _countArrayHeight);

        _groupMinimap.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _sizeImage.x);
        _groupMinimap.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _sizeImage.y);

        RectTransform container = _contentTransform.GetComponent <RectTransform>();

        container.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _sizeImage.x);
        container.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _sizeImage.y);

        TSSCore core = GetComponent <TSSCore>();

        _directAlphaProfile = Resources.Load <TSSProfile>("DirectAlpha");
        bool lastFlag;

        for (int j = 0; j < dirs.Length; j++)
        {
            functionLoadForAttach(dirs[j]);

            List <string> currentListImage = _attachFiles;
            int           currentArrayWidth = 0, currentArrayHeight = 0;
            lastFlag = j == dirs.Length - 1 ? true : false;

            GameObject groupObject = Instantiate(emptyGO, _contentTransform.transform);
            groupObject.name = j == 0 ? "Map" : groupObject.name = "Prep_" + j.ToString("00");
            groupObject.AddComponent <RectTransform>();
            groupObject.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _sizeImage.x);
            groupObject.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _sizeImage.y);

            if (j == 0)
            {
                TSSItem  newStateObject = new TSSItem();
                TSSState stateState     = core.AddState(newStateObject, (j).ToString());
                stateState.AddSelectionKey((KeyCode)((int)KeyCode.Alpha0));
            }
            else
            {
                groupObject.AddComponent <CanvasGroup>();
                TSSItem  newStateObject = groupObject.AddComponent <TSSItem>();
                TSSState stateState     = core.AddState(newStateObject, (j).ToString());
                stateState.AddSelectionKey((KeyCode)((int)KeyCode.Alpha1 + j - 1));
                newStateObject.profile = _directAlphaProfile;

                TSSProfile.ProfileRevert(newStateObject, _directAlphaProfile);
            }

            foreach (var element in currentListImage)
            {
                using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(element))
                {
                    yield return(uwr.SendWebRequest());

                    if (uwr.isNetworkError || uwr.isHttpError)
                    {
                        Debug.Log(uwr.error);
                    }
                    else
                    {
                        var texture = DownloadHandlerTexture.GetContent(uwr);
                        texture.Compress(true);
                        texture.Apply(false, true);

                        GameObject _currentMapElement = Instantiate(_prefabElementMap, groupObject.transform);
                        _currentMapElement.GetComponent <RawImage>().texture = texture;
                        _currentMapElement.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, texture.width);
                        _currentMapElement.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, texture.height);
                        _currentMapElement.GetComponent <RectTransform>().anchoredPosition = new Vector2(currentArrayWidth * 8000, currentArrayHeight * -8000);

                        currentArrayWidth++;
                        if (currentArrayWidth >= _countArrayWidth)
                        {
                            currentArrayHeight++;
                            currentArrayWidth = 0;
                        }
                    }
                    uwr.Dispose();
                    yield return(new WaitForSeconds(0.1f));
                }
            }
            if (lastFlag)
            {
                CreateMinimap();
            }
        }

        core.useEvents = true;
        TSS.Base.TSSBehaviour.RefreshAndStart();
        Destroy(emptyGO);
        _flagLoad = true;
    }