void Awake()
    {
        if (instance == null)
        {
            Debug.Log("Start MainController");
            instance = this;
            dijsktra = new DijsktraAlgorithm();
            ar       = new ARDisplayController();
            canvas   = GameObject.Find("Canvas").GetComponent <CanvasButtonScript>();
            canvas.StartCanvas();

            jsonReader = gameObject.GetComponent <JsonReader>();//new JsonReader();
            JsonReader.ReadState readState = jsonReader.ReadJsonData();
            Debug.Log("State " + readState);

            if (readState == JsonReader.ReadState.ReadOK)
            {
                GameObject.FindWithTag("Building").GetComponent <BuildingData>().GetAllFloorToList();
                canvas.StartNormalStateAppCanvas();
                stateDisplay = GameObject.Find("Canvas").GetComponent <StateDisplayController>();
            }
            else
            {
                canvas.ShowErrorCantReadFile(readState);
            }
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);
    }
    public void StartCanvas()
    {
        Screen.fullScreen = false;
        building          = GameObject.FindWithTag("Building").GetComponent <BuildingData>();
        Debug.Log(building.name);
        showingFloor   = building.floorList[0];
        searchShowList = new List <GameObject>();

        //canvasResolutionScript = gameObject.GetComponent<CanvasResolutionScript>();
        toastMessageScript = gameObject.GetComponent <ToastMessageScript>();
        stateDisplay       = gameObject.GetComponent <StateDisplayController>();
        stateDisplay.ShowToastMessage("ส่องกล้องไปยังจุดต่างๆ เช่น ป้ายบอกทาง เลขห้อง เพื่อเริ่มต้นระบุตำแหน่งของคุณ", false);
        stateDisplay.AddSound(SoundManager.SoundType.InitApp, 0);
        stateDisplay.PlaySoundQueue();

        hambergerButton = actionBar.gameObject.transform.Find("HambergerButton").gameObject;
        mapButton       = actionBar.gameObject.transform.Find("MapButton").gameObject;
        searchButton    = actionBar.gameObject.transform.Find("SearchButton").gameObject;
        appName         = actionBar.gameObject.transform.Find("AppName").gameObject;
        appNameText     = appName.GetComponent <Text>();

        backButton       = actionBar.gameObject.transform.Find("BackButton").gameObject;
        searchInputField = actionBar.gameObject.transform.Find("SearchInputField").gameObject;
        clearButton      = actionBar.gameObject.transform.Find("ClearSearchButton").gameObject;

        /* search */
        searchHelpText = searchPanel.transform.Find("HelpText").gameObject;
        searchList     = searchPanel.transform.Find("Scroll View").gameObject;
        viewPort       = searchList.gameObject.transform.Find("Viewport").gameObject;
        scrollbar      = searchList.gameObject.transform.Find("Scrollbar Vertical").gameObject;
        searchContent  = viewPort.gameObject.transform.Find("Content").gameObject;
        //searchContent.GetComponent<GridLayoutGroup>().cellSize = new Vector2(Screen.width - 50, 100);
        roomDataPanel      = searchPanel.transform.Find("RoomDataPanel").gameObject;
        roomDataDialog     = roomDataPanel.transform.Find("RoomDataDialog").gameObject;
        roomNameTitle      = roomDataDialog.transform.Find("RoomNameTitle").gameObject;
        roomMapImage       = roomDataDialog.transform.Find("RoomMapImage").gameObject;
        roomDesData        = roomDataDialog.transform.Find("RoomData").gameObject;
        roomNavigateButton = roomDataDialog.transform.Find("NavigateButton").gameObject;

        /* map */
        mapImage    = mapPanel.transform.Find("MapScrollViewArea").gameObject;
        rightButton = mapPanel.transform.Find("RightButton").gameObject;
        leftButton  = mapPanel.transform.Find("LeftButton").gameObject;
        mapControl  = mapImage.transform.Find("Mask/MapImage").gameObject.GetComponent <MapControlScript>();

        backButton.SetActive(false);
        searchInputField.SetActive(false);
        clearButton.SetActive(false);
    }
    public void StartCanvas()
    {
        Screen.fullScreen = false;

        toastMessageScript = gameObject.GetComponent <ToastMessageScript>();
        stateDisplay       = gameObject.GetComponent <StateDisplayController>();


        hambergerButton = actionBar.gameObject.transform.Find("HambergerButton").gameObject;
        mapButton       = actionBar.gameObject.transform.Find("MapButton").gameObject;
        searchButton    = actionBar.gameObject.transform.Find("SearchButton").gameObject;
        appName         = actionBar.gameObject.transform.Find("AppName").gameObject;
        appNameText     = appName.GetComponent <Text>();
        dbtext          = gameObject.transform.Find("DebugText").GetComponent <Text>();

        backButton       = actionBar.gameObject.transform.Find("BackButton").gameObject;
        searchInputField = actionBar.gameObject.transform.Find("SearchInputField").gameObject;
        clearButton      = actionBar.gameObject.transform.Find("ClearSearchButton").gameObject;

        /* search */
        searchHelpText     = searchPanel.transform.Find("HelpText").gameObject;
        searchList         = searchPanel.transform.Find("Scroll View").gameObject;
        viewPort           = searchList.gameObject.transform.Find("Viewport").gameObject;
        scrollbar          = searchList.gameObject.transform.Find("Scrollbar Vertical").gameObject;
        searchContent      = viewPort.gameObject.transform.Find("Content").gameObject;
        roomDataPanel      = searchPanel.transform.Find("RoomDataPanel").gameObject;
        roomDataDialog     = roomDataPanel.transform.Find("RoomDataDialog").gameObject;
        roomNameTitle      = roomDataDialog.transform.Find("RoomNameTitle").gameObject;
        roomMapImage       = roomDataDialog.transform.Find("RoomMapImage").gameObject;
        roomDesData        = roomDataDialog.transform.Find("DescriptionScrollView").GetChild(0).GetChild(0).Find("RoomData").gameObject;
        roomNavigateButton = roomDataDialog.transform.Find("ButtonViewport").GetChild(0).Find("NavButtonText").gameObject;

        /* map */
        mapImage    = mapPanel.transform.Find("MapScrollViewArea").gameObject;
        rightButton = mapPanel.transform.Find("RightButton").gameObject;
        leftButton  = mapPanel.transform.Find("LeftButton").gameObject;
        mapControl  = mapImage.transform.Find("Mask/MapImage").gameObject.GetComponent <MapControlScript>();

        /* error */
        errorDialog   = errorPanel.transform.Find("ErrorDialog").gameObject;
        errorHeadText = errorDialog.transform.Find("HeadText").gameObject;

        backButton.SetActive(false);
        searchInputField.SetActive(false);
        clearButton.SetActive(false);
    }
Exemple #4
0
 void Awake()
 {
     if (instance == null)
     {
         Debug.Log("Start MainController");
         instance   = this;
         dijsktra   = new DijsktraAlgorithm();
         ar         = new ARDisplayController();
         jsonReader = new JsonReader();
         jsonReader.ReadJsonData();
         stateDisplay = GameObject.Find("Canvas").GetComponent <StateDisplayController>();
         GameObject.FindWithTag("Building").GetComponent <BuildingData>().GetAllFloorToList();
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }