Skip to content
Snippets Groups Projects
StartMenue_mobile.cs 6.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI; //andr
    using UnityEngine.SceneManagement;
    using System.IO; //
    using UnityEngine.Video;//streaming
    using UnityEngine.Networking;
    //using static StreamingAssetLoader;
    //using static CheckServer;
    //using static CommunicationEvents;
    using static UIconfig;
    using static StreamingAssetLoader;
    
    using static CommunicationEvents;
    
    public class StartMenue_mobile : MonoBehaviour
    {
    
    
        //public int myUI_ID;
        public GameObject myself_GObj;
        //public GameObject parent_GObj;
        //public int backUI_ID;
        //public int optionsUI_ID;
        //public int failedUI_ID;
        public GameObject child1_GObj;
    
    
        public Text GObj_text;
        private bool uploadedCursorSkins = false;
    
            ScreenOptimization();
    
                start2_CheckOS_CheckConfig();
                checkOperationSystemAlreadyDone = true;
            }
            GObj_text.text = CommunicationEvents.Opsys + "";
    
            CheckServerA[1] = 1;
            CheckServerA[2] = 1;
            CheckServerA[3] = 1;
    
        }
    
        void start2_CheckOS_CheckConfig()
        {
    
            switch (CommunicationEvents.Opsys)
    
                    if (!checkPDP())
                    {
    
                        ResetStreamingAsset();
    
                        UIconfig.controlMode = CommunicationEvents.Opsys + 1;
                        NetworkJSON_Save();
                    }
    
                    NetworkJSON_Load();
                    checkOS();
                    ResetDataPath();
                    setMouse();
                    break;
                case 1:
    
                    {
                        ResetStreamingAsset();
    
                        UIconfig.controlMode = CommunicationEvents.Opsys + 1;
                        NetworkJSON_Save();
    
                    }
                    NetworkJSON_Load();
                    checkOS();
                    ResetDataPath();
                    setMouse();
    
                    break;
                default:
                    setMouse();
    
                    if (!checkPDP())
                    {
    
                        ResetStreamingAsset();
    
                        UIconfig.controlMode = CommunicationEvents.Opsys + 1;
                        NetworkJSON_Save();
                    }
    
                    NetworkJSON_Load();
                    checkOS();
                    setMouse();
                    break;
    
            if (UIconfig.MouseKeepingInWindow == true)
            {
                Cursor.lockState = CursorLockMode.Confined;
            }
            else
            {
                Cursor.lockState = CursorLockMode.None;
            }
    
        }
    
        private void Update()
        {
            
        }
    
        void checkOS()
        {
            if (CommunicationEvents.autoOSrecognition == true) {
                checkOS2();
            }
            else
            {
    
                //CommunicationEvents.Opsys = CommunicationEvents.Opsys_Default;
    
        }
    
        void checkOS2()
        {
            //https://docs.unity3d.com/ScriptReference/RuntimePlatform.html
            if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                
                Debug.Log("Windows OS detected");
                CommunicationEvents.Opsys = 0;
    
                return;
            }
            if (Application.platform == RuntimePlatform.Android)
            {
                Debug.Log("Android OS detected");
                CommunicationEvents.Opsys = 1;
    
            //CommunicationEvents.Opsys = CommunicationEvents.Opsys_Default;
    
        public void setMouse()
    
        }
    
    
        void ScreenOptimization()
        {
            Screen.orientation = ScreenOrientation.LandscapeLeft;
            
            UIconfig.screHeight = Screen.height;
            UIconfig.screWidth = Screen.width;
            CommunicationEvents.lastIP = CommunicationEvents.selecIP;
    
    
            /* //ScreenMatchMode.MatchWidthOrHeight:
                // If one axis has twice resolution and the other has half, it should even out if widthOrHeight value is at 0.5.
                // In normal space the average would be (0.5 + 2) / 2 = 1.25
                // In logarithmic space the average is (-1 + 1) / 2 = 0
                float scaleFactor = Mathf.Max(screenSize.x / m_ReferenceResolution.x, screenSize.y / m_ReferenceResolution.y);
    
                 float logWidth = Mathf.Log(screenSize.x / m_ReferenceResolution.x, kLogBase);
                 float logHeight = Mathf.Log(screenSize.y / m_ReferenceResolution.y, kLogBase);
                 float logWeightedAverage = Mathf.Lerp(logWidth, logHeight, m_MatchWidthOrHeight);
                 scaleFactor = Mathf.Pow(kLogBase, logWeightedAverage);
    
    
                //GameObject.Find("ASMenue").GetComponent;
                //Camera;
    
    
                //mainInputField.text = "Enter IP Here...";
    
            */
    
            UnityEngine.UI.CanvasScaler c = myself_GObj.GetComponent<UnityEngine.UI.CanvasScaler>();
            c.uiScaleMode = UnityEngine.UI.CanvasScaler.ScaleMode.ScaleWithScreenSize;
    
            UIconfig.refWidth = (int)Mathf.Round(c.referenceResolution[0]);
            UIconfig.refHeight = (int)Mathf.Round(c.referenceResolution[1]);
            //CommunicationEvents.scaleMatch = 0.5f;
    
            /*
                //float kLogBase=10;
                //CommunicationEvents.scaleMatch = Mathf.Max(CommunicationEvents.screWidth / CommunicationEvents.refWidth, CommunicationEvents.screHeight / CommunicationEvents.refHeight);
                //float logWidth = Mathf.Log(CommunicationEvents.screWidth / CommunicationEvents.refWidth, kLogBase);
                //float logHeight = Mathf.Log(CommunicationEvents.screHeight / CommunicationEvents.refHeight, kLogBase);
                //float logWeightedAverage = Mathf.Lerp(logWidth, logHeight, 0.5f);
                //CommunicationEvents.scaleMatch = Mathf.Pow(kLogBase, logWeightedAverage);
    
                //c.matchWidthOrHeight = CommunicationEvents.scaleMatch;
             /*
                    RectTransform rt = GetComponent<RectTransform>();
    
                    Vector3 screenSize = Camera.main.ViewportToWorldPoint(Vector3.up + Vector3.right);
    
                    screenSize *= 02;
    
                    float sizeY = screenSize.y / rt.rect.height;
                    float sizeX = screenSize.x / rt.rect.width;
    
                    rt.localScale = new Vector3(sizeX, sizeY, 1);
            */
            
    
        }
    
    
        public void toChild1()
        {
            ClearUIC();
            UIconfig.Andr_Start_menue_counter = 1;
            child1_GObj.SetActive(true); ;
    
    
        }
        
        /// <summary>
        /// Deactivates all Pages.
        /// </summary>
        private void ClearUIC()
        {
            
            for (int i = 0; i < myself_GObj.transform.childCount; i++)
            {
                myself_GObj.transform.GetChild(i).gameObject.SetActive(false);
            }
        }