Ejemplo n.º 1
0
    /// <summary>
    /// Takes input from the text box and sends it to the developer console
    /// for processing
    /// </summary>
    public void ProcessInput(TMPro.TMP_Text input)
    {
#if ENABLE_LEGACY_INPUT_MANAGER
        //Check we have not just pressed to close the console
        if (Input.GetKeyDown(toggleKey))
        {
            return;
        }
#elif ENABLE_INPUT_SYSTEM
        //Get if the input action is active (i.e just pressed to close the console)
        if (toggleConsoleInput != null)
        {
            if (toggleConsoleInput.triggered)
            {
                Debug.Log("Test");
                return;
            }
        }
#endif

        CommandResponse response = DeveloperConsole.ProcessConsoleInput(input.text);
        inputFeild.text = string.Empty;

        //If the command fails then print out a reason
        if (response.Type == CommandResponse.ResponseType.FAIL)
        {
            AddOutputLog(LogType.Log, response.Message);
        }
    }
    void Start()
    {
        //Initialize components
        rigid = GetComponent <Rigidbody>();

        //Initialize list of followers
        followers = new List <GameObject>();

        //Find total number of followers in the level
        totalFollowers = GameObject.Find("Followers").GetComponentsInChildren <Transform>().Length - 1;

        //Initialize number of followers lost
        lostFollowers = 0;

        //The main canvas of the scene
        Transform canvas = GameObject.Find("Canvas").transform;

        //Find and initialize text diplaying number of followers collected
        countText = canvas.Find("Count Text").GetComponentInChildren <TMPro.TMP_Text>();
        SetCountText();

        //Find the losing menu and deactivate it
        loseMenu = canvas.Find("Lose Menu").gameObject;
        loseMenu.SetActive(false);

        //Indicate the player has not lost
        hasLost = false;
    }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        _textComponent   = TextObject.GetComponent <TMPro.TMP_Text>();
        _cursorComponent = CursorObject.GetComponent <UnityEngine.UI.Image>();

        UpdateForIndex();
    }
Ejemplo n.º 4
0
 private void Start()
 {
     m_healthImage     = GameObject.Find("HealthImage").GetComponent <Image>();
     m_healthText      = m_healthImage.transform.GetChild(1).GetComponent <TMPro.TMP_Text>();
     m_healthText.text = m_currentHealth.ToString();
     CurveFlowManager.SetValue("CurrentHealth", (float)m_currentHealth / m_maxHealth);
 }
Ejemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     player  = GameObject.Find("Player");
     note    = transform.Find("Text (TMP)").gameObject.GetComponent <TMPro.TMP_Text>();
     lockup  = transform.Find("padlockup").gameObject;
     lockbut = transform.Find("padlockbut").gameObject;
 }
Ejemplo n.º 6
0
    public void NewGame()
    {
        Debug.Log("Resetting the game board.");

        turn = Random.Range(1, 10) > 5;

        gameover = false;

        row1 = "";
        row2 = "";
        row3 = "";
        col1 = "";
        col2 = "";
        col3 = "";
        forw = "";
        back = "";

        var go = GameObject.FindObjectsOfType <Button>();

        if (go != null)
        {
            foreach (Button b in go)
            {
                if (b.name.Length == 2)
                {
                    TMPro.TMP_Text text = b.GetComponentInChildren <TMPro.TMP_Text>();
                    text.SetText(" ");
                }
            }
        }
    }
Ejemplo n.º 7
0
        void Awake()
        {
            // Get a reference to the TMP text component if one already exists otherwise add one.
            // This example show the convenience of having both TMP components derive from TMP_Text. 
            if (ObjectType == 0)
                m_text = GetComponent<TextMeshPro>() ?? gameObject.AddComponent<TextMeshPro>();
            else
                m_text = GetComponent<TextMeshProUGUI>() ?? gameObject.AddComponent<TextMeshProUGUI>();

            // Load a new font asset and assign it to the text object.
            m_text.font = Resources.Load<TMP_FontAsset>("Fonts & Materials/IMPACT SDF");

            // Load a new material preset which was created with the context menu duplicate.
            m_text.fontSharedMaterial = Resources.Load<Material>("Fonts & Materials/IMPACT SDF - Drop Shadow");

            // Set the size of the font.
            m_text.fontSize = 120;

            // Set the text
            m_text.text = "A <#0080ff>simple</color> line of text.";

            // Get the preferred width and height based on the supplied width and height as opposed to the actual size of the current text container.
            Vector2 size = m_text.GetPreferredValues(Mathf.Infinity, Mathf.Infinity);
            
            // Set the size of the RectTransform based on the new calculated values.
            m_text.rectTransform.sizeDelta = new Vector2(size.x, size.y);
        }
Ejemplo n.º 8
0
    int EnemyTotal; // sum of all enemys in each wave.

    // Start is called before the first frame update
    void Start()
    {
        CounterText      = GetComponent <TMPro.TMP_Text>();
        CounterText.text = "00 / 00";

        GetWaveController = FindObjectOfType <WaveController>(); // find the wave controller
    }
Ejemplo n.º 9
0
        /// <summary>
        /// 启动
        /// </summary>
        /// <param name="targetPosition">目标位置</param>
        public void Run(Vector2 targetPosition)
        {
            m_RectTransform = GetComponent <RectTransform>();
            m_CanvasGroup   = GetComponent <CanvasGroup>();
            m_Field         = transform.Find("Field").GetComponent <TMPro.TMP_Text>();

            m_RectTransform.anchoredPosition = Vector2.zero;
            m_RectTransform.localScale       = Vector3.one;
            m_CanvasGroup.alpha = 1;
            m_Field.text        = Text;
            m_BeginTime         = Time.realtimeSinceStartup;
            m_TargetPosition    = targetPosition;
            m_Offset            = Random.Range(Curves.birthOffsetBegin, Curves.birthOffsetEnd);
            m_Angle             = Random.Range(Curves.birthAngleBegin, Curves.birthAngleEnd);
            m_Duration          = 0;

            foreach (Keyframe key in Curves.offsetX.keys)
            {
                m_Duration = Mathf.Max(m_Duration, key.time);
            }
            foreach (Keyframe key in Curves.offsetY.keys)
            {
                m_Duration = Mathf.Max(m_Duration, key.time);
            }
            foreach (Keyframe key in Curves.alpha.keys)
            {
                m_Duration = Mathf.Max(m_Duration, key.time);
            }
            foreach (Keyframe key in Curves.scale.keys)
            {
                m_Duration = Mathf.Max(m_Duration, key.time);
            }

            Update();
        }
Ejemplo n.º 10
0
    void Update()
    {
        if (!Application.isPlaying)
        {
            if (source == null)
            {
                source = GetComponent <TMPro.TMP_Text> ();
            }
            string formattedText = source.text;
            if (cols != null)
            {
                for (int i = 0; i < cols.Length; i++)
                {
                    string key     = $"<color={cols[i].name}>";
                    string replace = $"<color=#{ColorUtility.ToHtmlStringRGB (cols[i].colour)}>";
                    formattedText = formattedText.Replace(key, replace);
                }
            }

            if (sizes != null)
            {
                for (int i = 0; i < sizes.Length; i++)
                {
                    string key     = $"<size={sizes[i].name}>";
                    string replace = $"<size={sizes[i].fontSize}>";
                    formattedText = formattedText.Replace(key, replace);
                }
            }

            target.text = formattedText;
        }
    }
Ejemplo n.º 11
0
 public simplex_legacy(int variablesNum, int restrictionsNum, double[] indecisMain,
                       bool toMax, restriction[] rests, TMPro.TMP_Text solutionText)
 {
     solText      = solutionText;
     solText.text = "";
     num_v        = variablesNum;
     num_l        = restrictionsNum;
     function     = indecisMain;
     way          = toMax;
     fm           = new double[num_l];
     sign         = new int[num_l];
     system       = new double[num_l][];
     for (int i = 0; i < num_l; i++)
     {
         fm[i]     = rests[i].b;
         sign[i]   = rests[i].type;
         system[i] = new double[num_v];
     }
     for (int i = 0; i < num_l; i++)
     {
         for (int j = 0; j < num_v; j++)
         {
             system[i][j] = rests[i].indexes[j];
         }
     }
 }
Ejemplo n.º 12
0
    void Awake()
    {
        txt            = GameObject.Find("HRText").GetComponent <TMPro.TMP_Text>();
        heartText      = GameObject.Find("hrui").GetComponent <TMPro.TMP_Text>();
        beats          = new List <Beat>();
        onsetFeatures  = new List <Onset>();
        chromaFeatures = new List <Chroma>();
        musicPlayer    = GetComponent <MusicPlayer>();
        audioSource    = GetComponent <AudioSource>();
        rhythmPlayer   = GetComponent <RhythmPlayer>();

        rhythmData.GetIntersectingFeatures(onsetFeatures, 0, 200);
        rhythmData.GetIntersectingFeatures(beats, 0, 200);
        rhythmData.GetFeatures(chromaFeatures, 0, 200);

//        UnityEngine.Debug.Log(onsetFeatures);


        foreach (var onset in onsetFeatures) //여기서생성
        {
            SpawnRandomFootNote(onset.timestamp).importance = onset.strength;
            SpawnRandomNote(onset.timestamp).importance     = onset.strength;
        }
        //foreach(var chroma in chromaFeatures)
        {
            //    SpawnRandomNote(chroma.timestamp);
        }


        rhythmPlayer.Play();
    }
Ejemplo n.º 13
0
 public meshController(float b, float l, float t, TMPro.TMP_Text text)
 {
     this.b    = b;
     this.l    = l;
     this.t    = t;
     this.text = text;
 }
Ejemplo n.º 14
0
    private void LoadCharacter()
    {
        GameObject LBG      = GameObject.Find("LocationBasedGame");
        int        charType = gameManager.charType;

        if (charType == 0)
        {
            player = Instantiate(character1, new Vector3(0, 0, 0), Quaternion.identity);
        }
        else
        {
            player = Instantiate(character2, new Vector3(0, 0, 0), Quaternion.identity);
        }

        player.AddComponent(typeof(ImmediatePositionWithLocationProvider));
        player.AddComponent(typeof(RotateWithLocationProvider));
        player.transform.parent = LBG.transform;
        // set a tag for the user's player character
        player.tag = "UserCharacter";
        // Slime model tiny - using this to increase size
        player.transform.localScale += new Vector3(3.0f, 3.0f, 3.0f);
        mainCamera.transform.parent  = player.transform;

        TMPro.TMP_Text avatarNameField = GameObject.Find("AvatarName").GetComponent <TMPro.TMP_Text>();
        string         displayName     = gameManager.displayName;

        if (displayName != null)
        {
            avatarNameField.SetText(gameManager.displayName);
        }
    }
Ejemplo n.º 15
0
    IEnumerator TypewriterText(TMPro.TMP_Text text, string line, Speaker speaker)
    {
        text.text = "";
        text.maxVisibleCharacters = 0;
        string[] words = line.Split(' ');
        for (int i = 0; i < words.Length; i++)
        {
            text.text += words[i];
            text.text += " ";
            for (int j = 0; j < words[i].Length; j++)
            {
                text.maxVisibleCharacters++;
                AudioSource src      = Instantiate(audioPrefab.gameObject).GetComponent <AudioSource>();
                float       varience = .04f;
                src.pitch  += UnityEngine.Random.value * varience - varience * .5f;
                src.volume /= j;
                src.PlayOneShot(text_sounds[(int)speaker]);
                StartCoroutine(KillAudio(src));

                yield return(new WaitForSeconds(Input.GetMouseButton(0) ? 0 : config.inter_char_time));
            }

            text.maxVisibleCharacters++;

            yield return(null); //unnecessary but I hate loops
        }
    }
Ejemplo n.º 16
0
 private void Awake()
 {
     nomeText     = transform.GetChild(0).gameObject.GetComponent <TMPro.TMP_Text>();
     cargaText    = transform.GetChild(1).gameObject.GetComponent <TMPro.TMP_Text>();
     creditosText = transform.GetChild(2).gameObject.GetComponent <TMPro.TMP_Text>();
     semAcesso    = transform.GetChild(3).gameObject;
     ocultoText   = transform.GetChild(5).gameObject;
 }
Ejemplo n.º 17
0
    public TMPro.TMP_Text playerScore;                              //creates text object

    public void Awake()
    {
        playerScore = FindObjectOfType <TMPro.TMP_Text>();           //finds textMeshPro object and defines playerScore
        //if (playerScore)
        //    Debug.Log("Score text is found!!");                     //debug's whether it is found or not
        //else
        //    Debug.Log("Score text not found, try again!!");
    }
Ejemplo n.º 18
0
 private void Update()
 {
     if (Score)
     {
         scoreText      = Score.GetComponent <TMPro.TMP_Text>();
         scoreText.text = LevelController.instance.Score.ToString();
     }
 }
Ejemplo n.º 19
0
 public void Clear()
 {
     m_Slot   = null;
     m_Slider = null;
     m_ListBuffIcon.Clear();
     m_NameField = null;
     m_Character = null;
 }
 void Start()
 {
     game         = GameObject.FindWithTag("Game").GetComponent <GameManager>();
     Text         = GetComponent <TMPro.TMP_Text>();
     regColor     = Text.color;
     onMouseColor = Color.green;
     Size         = new Vector3(this.transform.localScale.x * 0.07f, this.transform.localScale.y * 0.07f, this.transform.localScale.z * 0.07f);
 }
    public void Set(Vector2 start, Vector2 end, string s, StateMachineData.Transition t)
    {
        transitions.Add(t);

        // Self Transition?
        if (t.from == t.to)
        {
            lineRenderer.enabled = false;
            selfTransitionArrow.SetActive(true);
            normalTransitionArrow.SetActive(false);

            transform.position = start;
            // set ref
            coll = selfColl;
            text = selfText;
        }
        else
        {
            // Line Pos
            Vector2 e = Vector2.MoveTowards(end, start, Appdata.circleSize + (Appdata.arrowSize / 2f));
            lineRenderer.positionCount = 2;
            lineRenderer.SetPositions(new Vector3[] { start, e });
            lineRenderer.sortingOrder = -10;

            // Arrow Pos
            e = Vector2.MoveTowards(e, start, Appdata.arrowSize / 2f);
            arrow.transform.position = e;

            // Arrow Rot
            arrow.transform.rotation = Quaternion.Euler(0f, 0f, Vector2.SignedAngle(Vector2.up, end - start));

            // Text Pos
            Vector2 ts = Vector2.MoveTowards(start, end, Appdata.circleSize);
            text.gameObject.transform.position = Vector2.Lerp(ts, e, 0.5f);

            // Text Rot
            float textRot = (arrow.transform.rotation.eulerAngles.z + 90f) % 360;
            if (textRot > 90f && textRot < 270f)
            {
                text.gameObject.transform.rotation = Quaternion.Euler(0f, 0f, textRot + 180f);
                ((RectTransform)text.gameObject.transform).pivot = new Vector2(0.5f, 0.85f);
            }
            else
            {
                text.gameObject.transform.rotation = Quaternion.Euler(0f, 0f, textRot);
            }

            // Coll Pos
            coll.gameObject.transform.position = ts;
            ((BoxCollider2D)coll).size         = new Vector2(Vector2.Distance(start, end) - (Appdata.circleSize * 2f), 0.35f);
            coll.offset = new Vector2(((BoxCollider2D)coll).size.x / 2f, 0f);

            // Coll Rot
            coll.gameObject.transform.rotation = Quaternion.Euler(0f, 0f, textRot);
        }

        text.SetText(s);
    }
Ejemplo n.º 22
0
 // Start is called before the first frame update
 void Awake()
 {
     rate = Squiggle_Maker.rate;
     //Debug.Log("Squiggle rate:" + rate);
     tmp = GetComponent <TMPro.TMP_Text>();
     if (prefab)
     {
     }
 }
Ejemplo n.º 23
0
    public void MeshSwitch()
    {
        if (camControl == null)
        {
            Debug.Log("CamControl is null.");
            camControl = FindObjectOfType <CameraController>();
        }
        GameObject currentGO   = camControl.selectedObj.gameObject;
        ObjectData currentData = currentGO.GetComponent <ObjectData>();

        TMPro.TMP_Text buttonName = GetComponentInChildren <TMPro.TMP_Text>();

        if (CompareTag("Door"))
        {
            foreach (GameObject door in currentData.doorOptions)
            {
                if (buttonName.text == door.name)
                {
                    door.SetActive(true);
                }
                else
                {
                    door.SetActive(false);
                }
            }
        }

        if (CompareTag("Drawer"))
        {
            foreach (GameObject drawer in currentData.drawerOptions)
            {
                if (buttonName.text == drawer.name)
                {
                    drawer.SetActive(true);
                }
                else
                {
                    drawer.SetActive(false);
                }
            }
        }

        if (CompareTag("ApplianceOpt"))
        {
            foreach (GameObject washer in currentData.applianceOptions)
            {
                if (buttonName.text == washer.name)
                {
                    washer.SetActive(true);
                }
                else
                {
                    washer.SetActive(false);
                }
            }
        }
    }
Ejemplo n.º 24
0
 private void OnTriggerExit(Collider other)
 {
     if (other.CompareTag("Pickupable") && !picked)
     {
         pickupText = null;
         pick       = null;
         canPick    = false;
     }
 }
Ejemplo n.º 25
0
 public void SetSubtitlesText(string text)
 {
     TMPro.TMP_Text textComponent = subtitlesText.GetComponentInChildren(typeof(TMPro.TMP_Text)).GetComponent <TMPro.TMP_Text>();
     textComponent.text = "";
     if (text != null)
     {
         textComponent.text = text;
     }
 }
Ejemplo n.º 26
0
 void Start()
 {
     loseText     = loseState.GetComponent <TMPro.TMP_Text>();
     loseImg      = loseState.GetComponentInChildren <Image>();
     cam          = Camera.main;
     imgfx        = cam.GetComponent <ImageEffect>();
     playerScript = GetComponent <PlayerInputController>();
     audioManager = FindObjectOfType <AudioManager>();
 }
Ejemplo n.º 27
0
    private void Awake()
    {
        //El jugador comienza con 10 céntimos.
        coins = 10;

        //Fuerzo por si acaso el número de vidas
        lifes = 5;

        //Dice a Unity de hacer que este script se mantenga entre nivel y nivel.
        DontDestroyOnLoad(gameObject);

        //Encuentra y asigna elementos de la interfaz:
        PressE                 = GameObject.Find("PressE");
        screenfade             = GameObject.Find("Screenfade").GetComponent <Image>();
        pointCounterHolder     = GameObject.Find("PointCounterHolder");
        pointsCounter          = GameObject.Find("PointCounter").GetComponent <TMPro.TMP_Text>();
        muteAudio              = GameObject.Find("MuteAudio");
        blueKey                = GameObject.Find("BlueKey");
        redKey                 = GameObject.Find("RedKey");
        message                = GameObject.Find("MessageHolder");
        pauseText              = GameObject.Find("Pause");
        returnToMenuButton     = GameObject.Find("ReturnToMenu");
        lifeCounterHolder      = GameObject.Find("LifeCounterHolder");
        lifeCounter            = GameObject.Find("LifeCounter");
        levelSummaryBackground = GameObject.Find("LevelSummaryBackground");
        levelSummaryTitle      = GameObject.Find("LevelSummaryTitle");
        levelSummaryContinue   = GameObject.Find("LevelSummaryContinue");
        levelSummaryCoins      = GameObject.Find("LevelSummaryCoins");
        levelSummaryEnemies    = GameObject.Find("LevelSummaryEnemies");
        levelSummaryTime       = GameObject.Find("LevelSummaryTime");

        //Desactiva elementos de la interfaz que solo se usen durante el juego.
        PressE.SetActive(false);
        pointCounterHolder.SetActive(false);
        blueKey.SetActive(false);
        redKey.SetActive(false);
        message.SetActive(false);
        pauseText.SetActive(false);
        returnToMenuButton.SetActive(false);
        lifeCounterHolder.SetActive(false);
        levelSummaryBackground.SetActive(false);
        levelSummaryTitle.SetActive(false);
        levelSummaryCoins.SetActive(false);
        levelSummaryContinue.SetActive(false);
        levelSummaryEnemies.SetActive(false);
        levelSummaryTime.SetActive(false);

        //Hace que la pantalla en negro desaparezca enseñando el menu principal.
        screenfade.CrossFadeAlpha(0f, 1f, false);

        //Inicializa la lista de llaves.
        keysOwned = new List <string>();

        //Activa la música el menu principal.
        ASs = GetComponents <AudioSource>();
        ASs[1].Play();
    }
Ejemplo n.º 28
0
 private static void doAwake(TMPro.TMP_Text __instance)
 {
     try {
         __instance.text = GetRandomString(
             (string)typeof(TMPro.TMP_Text)
             .GetField("m_text", AccessTools.all)
             .GetValue(__instance as TMPro.TMP_Text));
     } catch (ArgumentException) { }
 }
Ejemplo n.º 29
0
    static void ConvertToUnityGuiText(MenuCommand menuCommand)
    {
        TMPro.TMP_Text text           = (TMPro.TMP_Text)menuCommand.context;
        GameObject     textGameObject = text.gameObject;
        string         textValue      = text.text;

        Object.DestroyImmediate(text);
        textGameObject.AddComponent <Text>().text = textValue;
    }
    public void Awake()
    {
        //referencing UI_Controller_Script
        Game_Manager  = GameObject.Find("Game_Manager");
        ui_controller = Game_Manager.GetComponent <UI_Controller_Script>();

        back_button = GameObject.Find("back_button").GetComponent <Button>();
        back_button.onClick.AddListener(ui_controller.back_button);

        //reading name and alignment from the inputfield
        input_alignment = GameObject.Find("input_alignment").GetComponent <InputField>();
        input_alignment.onEndEdit.AddListener(delegate { ui_controller.read_alignment(input_alignment); });
        inputfield_name = GameObject.Find("inputfield_name").GetComponent <InputField>();
        inputfield_name.onEndEdit.AddListener(delegate { ui_controller.read_char_name(inputfield_name); });

        //reading race and class from dropdowns
        Dropdown_Race = GameObject.Find("Dropdown_Race").GetComponent <TMPro.TMP_Dropdown>();
        Dropdown_Race.onValueChanged.AddListener(delegate { ui_controller.race_selected(Dropdown_Race); });
        Dropdown_Class = GameObject.Find("Dropdown_Class").GetComponent <TMPro.TMP_Dropdown>();
        Dropdown_Class.onValueChanged.AddListener(delegate { ui_controller.class_selected(Dropdown_Class); });

        //referencing ability buttons
        strength_button     = GameObject.Find("strength_button").GetComponent <Button>();
        dexterity_button    = GameObject.Find("dexterity_button").GetComponent <Button>();
        constitution_button = GameObject.Find("constitution_button").GetComponent <Button>();
        intelligence_button = GameObject.Find("intelligence_button").GetComponent <Button>();
        wisdom_button       = GameObject.Find("wisdom_button").GetComponent <Button>();
        charisma_button     = GameObject.Find("charisma_button").GetComponent <Button>();

        //referencing output Gameobjects
        score_strength     = GameObject.Find("score_strength").GetComponent <TMPro.TMP_Text>();
        score_dexterity    = GameObject.Find("score_dexterity").GetComponent <TMPro.TMP_Text>();
        score_constitution = GameObject.Find("score_constitution").GetComponent <TMPro.TMP_Text>();
        score_intelligence = GameObject.Find("score_intelligence").GetComponent <TMPro.TMP_Text>();
        score_wisdom       = GameObject.Find("score_wisdom").GetComponent <TMPro.TMP_Text>();
        score_charisma     = GameObject.Find("score_charisma").GetComponent <TMPro.TMP_Text>();

        //adding listener functions to roll buttons
        strength_button.onClick.AddListener(delegate { ui_controller.ability_button_clicked(strength_button, score_strength, 's'); });
        dexterity_button.onClick.AddListener(delegate { ui_controller.ability_button_clicked(dexterity_button, score_dexterity, 'd'); });
        constitution_button.onClick.AddListener(delegate { ui_controller.ability_button_clicked(constitution_button, score_constitution, 'c'); });
        intelligence_button.onClick.AddListener(delegate { ui_controller.ability_button_clicked(intelligence_button, score_intelligence, 'i'); });
        wisdom_button.onClick.AddListener(delegate { ui_controller.ability_button_clicked(wisdom_button, score_wisdom, 'w'); });
        charisma_button.onClick.AddListener(delegate { ui_controller.ability_button_clicked(charisma_button, score_charisma, 'm'); }); //I use m to flag "charisma"

        //referencing output button and text area
        json_button = GameObject.Find("json_button").GetComponent <Button>();
        json_text   = GameObject.Find("json_text").GetComponent <TMPro.TMP_Text>(); //inputfield was used so grader would be able to copy/paste JSON output

        //adding listener function to the output button
        json_button.onClick.AddListener(delegate { ui_controller.json_button_clicked(json_text); });


        json_copy = GameObject.Find("json_copy").GetComponent <Button>();
        json_copy.onClick.AddListener(delegate { ui_controller.copy_json(json_text); });
    }
Ejemplo n.º 31
0
        void OnEnable()
        {
            if (m_textComponent == null) m_textComponent = gameObject.GetComponent<TMP_Text>();

#if UNITY_EDITOR
            TMPro_EventManager.SPRITE_ASSET_PROPERTY_EVENT.Add(ON_SPRITE_ASSET_PROPERTY_CHANGED);
#endif

            LoadSpriteAsset(m_spriteAsset);
        }
Ejemplo n.º 32
0
    private void Awake()
    {
        UIManager.Instacne.m_EnemyHPBar = this;

        m_NameText         = GetComponentInChildren <TMPro.TMP_Text>();
        m_Image            = GetComponent <UnityEngine.UI.Image>();
        m_Material         = m_Image.material;
        m_Image.enabled    = false;
        m_NameText.enabled = false;
    }
Ejemplo n.º 33
0
        private bool InternalRegisterTextElementForGraphicRebuild(TMP_Text element)
        {
            int id = element.GetInstanceID();

            if (this.m_GraphicQueueLookup.ContainsKey(id))
                return false;

            m_GraphicQueueLookup[id] = id;
            this.m_GraphicRebuildQueue.Add(element);

            return true;
        }
Ejemplo n.º 34
0
        // TEXT INPUT COMPONENT RELATED FUNCTIONS
        /// <summary>
        /// 
        /// </summary>
        /// <param name="textComponent">A reference to the text object.</param>
        /// <param name="position">Position to check for intersection.</param>
        /// <param name="camera">The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay.</param>
        /// <returns></returns>
        public static CaretInfo GetCursorInsertionIndex(TMP_Text textComponent, Vector3 position, Camera camera)
        {
            int index = TMP_TextUtilities.FindNearestCharacter(textComponent, position, camera, false);

            RectTransform rectTransform = textComponent.rectTransform;

            // Convert position into Worldspace coordinates
            ScreenPointToWorldPointInRectangle(rectTransform, position, camera, out position);

            TMP_CharacterInfo cInfo = textComponent.textInfo.characterInfo[index];

            // Get Bottom Left and Top Right position of the current character
            Vector3 bl = rectTransform.TransformPoint(cInfo.bottomLeft);
            //Vector3 tl = rectTransform.TransformPoint(new Vector3(cInfo.bottomLeft.x, cInfo.topRight.y, 0));
            Vector3 tr = rectTransform.TransformPoint(cInfo.topRight);
            //Vector3 br = rectTransform.TransformPoint(new Vector3(cInfo.topRight.x, cInfo.bottomLeft.y, 0));

            float insertPosition = (position.x - bl.x) / (tr.x - bl.x);

            if (insertPosition < 0.5f)
                return new CaretInfo(index, CaretPosition.Left);
            else
                return new CaretInfo(index, CaretPosition.Right);
        }
Ejemplo n.º 35
0
        public void AddInlineGraphicsChild()
        {
            if (m_inlineGraphic != null)
            {
                //Debug.LogWarning("A child Inline Graphics object already exists.");
                return;
            }
            
            GameObject inlineGraphicObj = new GameObject("Inline Graphic");

            m_inlineGraphic = inlineGraphicObj.AddComponent<InlineGraphic>();

            m_inlineGraphicRectTransform = inlineGraphicObj.GetComponent<RectTransform>();
            m_inlineGraphicCanvasRenderer = inlineGraphicObj.GetComponent<CanvasRenderer>();

            m_inlineGraphicRectTransform.SetParent(transform, false);

            m_inlineGraphicRectTransform.localPosition = Vector3.zero;
            m_inlineGraphicRectTransform.anchoredPosition3D = Vector3.zero;

            m_inlineGraphicRectTransform.sizeDelta = Vector2.zero;
            m_inlineGraphicRectTransform.anchorMin = Vector2.zero;
            m_inlineGraphicRectTransform.anchorMax = Vector2.one;

            m_textComponent = GetComponent<TMP_Text>();
        }
 /// <summary>
 /// Function to unregister elements which no longer require a rebuild.
 /// </summary>
 /// <param name="element"></param>
 public static void UnRegisterTextElementForRebuild(TMP_Text element)
 {
     TMP_UpdateManager.instance.InternalUnRegisterTextElementForGraphicRebuild(element);
     TMP_UpdateManager.instance.InternalUnRegisterTextElementForLayoutRebuild(element);
 }
        private void InternalUnRegisterTextElementForLayoutRebuild(TMP_Text element)
        {
            //if (this.m_PerformingLayoutRebuild)
            //{
            //    Debug.LogError((object)string.Format("Trying to remove {0} from rebuild list while we are already inside a rebuild loop. This is not supported.", (object)element));
            //}
            //else
            //{
                int id = element.GetInstanceID();

                //element.LayoutComplete();
                TMP_UpdateManager.instance.m_LayoutRebuildQueue.Remove(element);
                m_LayoutQueueLookup.Remove(id);
            //}
        }
Ejemplo n.º 38
0
    public override void OnEnable()
    {
        base.OnEnable();
        //Debug.Log("New Instance of SDF Material Editor with ID " + this.GetInstanceID());

        // Get the UI Skin and Styles for the various Editors
        TMP_UIStyleManager.GetUIStyles();

        // Get Shader Property IDs
        ShaderUtilities.GetShaderPropertyIDs();

        // Initialize the Event Listener for Undo Events.
        Undo.undoRedoPerformed += OnUndoRedo;
        //Undo.postprocessModifications += OnUndoRedoEvent;

        // Get a reference to the text object component.
        if (Selection.activeGameObject != null)
        {
            m_textComponent = Selection.activeGameObject.GetComponent<TMP_Text>();
        }
    }
Ejemplo n.º 39
0
        /// <summary>
        /// Function returning the index of the character whose origin is closest to the cursor.
        /// </summary>
        /// <param name="textComponent">A reference to the text object.</param>
        /// <param name="position">Position to check for intersection.</param>
        /// <param name="camera">The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay.</param>
        /// <param name="cursor">The position of the cursor insertion position relative to the position.</param>
        /// <returns></returns>
        public static int GetCursorIndexFromPosition(TMP_Text textComponent, Vector3 position, Camera camera, out CaretPosition cursor)
        {
            int index = TMP_TextUtilities.FindNearestCharacter(textComponent, position, camera, false);

            RectTransform rectTransform = textComponent.rectTransform;

            // Convert position into Worldspace coordinates
            ScreenPointToWorldPointInRectangle(rectTransform, position, camera, out position);

            TMP_CharacterInfo cInfo = textComponent.textInfo.characterInfo[index];

            // Get Bottom Left and Top Right position of the current character
            Vector3 bl = rectTransform.TransformPoint(cInfo.bottomLeft);
            Vector3 tr = rectTransform.TransformPoint(cInfo.topRight);

            float insertPosition = (position.x - bl.x) / (tr.x - bl.x);

            if (insertPosition < 0.5f)
            {
                cursor = CaretPosition.Left;
                return index;
            }
            else
            {
                cursor = CaretPosition.Right;
                return index + 1;
            }
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Function to find the nearest character to position.
        /// </summary>
        /// <param name="text">A reference to the TMP Text component.</param>
        /// <param name="position">Position to check for intersection.</param>
        /// <param name="camera">The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay.</param>
        /// <param name="visibleOnly">Only check for visible characters.</param>
        /// <returns></returns>
        public static int FindNearestCharacter(TMP_Text text, Vector3 position, Camera camera, bool visibleOnly)
        {
            RectTransform rectTransform = text.rectTransform;

            float distanceSqr = Mathf.Infinity;
            int closest = 0;

            // Convert position into Worldspace coordinates
            ScreenPointToWorldPointInRectangle(rectTransform, position, camera, out position);

            for (int i = 0; i < text.textInfo.characterCount; i++)
            {
                // Get current character info.
                TMP_CharacterInfo cInfo = text.textInfo.characterInfo[i];
                if (visibleOnly && !cInfo.isVisible)
                    continue;

                // Get Bottom Left and Top Right position of the current character
                Vector3 bl = rectTransform.TransformPoint(cInfo.bottomLeft);
                Vector3 tl = rectTransform.TransformPoint(new Vector3(cInfo.bottomLeft.x, cInfo.topRight.y, 0));
                Vector3 tr = rectTransform.TransformPoint(cInfo.topRight);
                Vector3 br = rectTransform.TransformPoint(new Vector3(cInfo.topRight.x, cInfo.bottomLeft.y, 0));

                if (PointIntersectRectangle(position, bl, tl, tr, br))
                    return i;

                // Find the closest corner to position.
                float dbl = DistanceToLine(bl, tl, position);
                float dtl = DistanceToLine(tl, tr, position);
                float dtr = DistanceToLine(tr, br, position);
                float dbr = DistanceToLine(br, bl, position);

                float d = dbl < dtl ? dbl : dtl;
                d = d < dtr ? d : dtr;
                d = d < dbr ? d : dbr;

                if (distanceSqr > d)
                {
                    distanceSqr = d;
                    closest = i;
                }
            }

            return closest;
        }