Search Unity

Text value different to "string"

Discussion in 'Scripting' started by juan_589migue, Jun 28, 2021.

  1. juan_589migue

    juan_589migue

    Joined:
    Dec 31, 2020
    Posts:
    9
    Hi community, thanks for your support, i need your help, here i have c# code :
    i needing that the text get component has the screen.height value. sorry bucaouse these code seens repetitive in else but i need when the camera orientation event its response.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class ScreenRotate : MonoBehaviour
    7. {
    8.     public GameObject hobject;
    9.     public GameObject wobject;
    10.  
    11.  
    12.    
    13.     void Start()
    14.     {
    15.             if (Screen.orientation == ScreenOrientation.Landscape)
    16.             {
    17.  
    18.                 hobject.GetComponent<InputField>().text = Screen.height; // help here i need the text value is the //screen.height value without ""string.
    19.          
    20.                 wobject.GetComponent<InputField>().text = Screen.weight; // help here needing the screen.weight //value without ""string.
    21.  
    22.             }
    23.             else
    24.         {
    25.             hobject.GetComponent<InputField>().text = Screen.height;
    26.  
    27.             wobject.GetComponent<InputField>().text = Screen.weight;
    28.         }
    29.     }
    30.  
    31.  
    32.     void Update()
    33.     {
    34.        
    35.     }
    36. }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,686