Пример #1
0
    void Start()
    {
        #if UNITY_EDITOR
        ServicePointManager.ServerCertificateValidationCallback = Validator;
        #endif

        // Connect to the app service
        serviceAPI = new ServiceAPI(Constants.apiKey, Constants.secretKey);

        // Build the log service
        logService = serviceAPI.BuildLogService();

        // Build the storage service
        storageService = serviceAPI.BuildStorageService();

        // Get the device number
        deviceId = SystemInfo.deviceUniqueIdentifier;

        // Log the event
        logService.SetEvent("[DEMO] Feedback", "Landed", logCallBack);

        #region GUI Styling

        containerRect = new Rect(Screen.width * ((1 - containerWidth) / 2),
                                 Screen.height * ((1 - containerHeight) / 2),
                                 Screen.width * containerWidth,
                                 Screen.height * containerHeight);

        // Set the header style
        headerStyle               = new GUIStyle(activeSkin.customStyles[0]);
        headerStyle.fontSize      = (int)(Screen.height * headerFontScaling);
        headerStyle.padding.left  = (int)(containerRect.width * labelHorPadding);
        headerStyle.padding.right = (int)(containerRect.width * labelHorPadding);

        // Set the label style
        labelStyle               = activeSkin.label;
        labelStyle.fontSize      = (int)(Screen.height * labelFontScaling);
        labelStyle.padding.left  = (int)(containerRect.width * labelHorPadding);
        labelStyle.padding.right = (int)(containerRect.width * labelHorPadding);

        // set the error msg style
        alertMsgStyle               = new GUIStyle(activeSkin.customStyles[1]);
        alertMsgStyle.fontSize      = labelStyle.fontSize;
        alertMsgStyle.padding.left  = (int)(containerRect.width * labelHorPadding);
        alertMsgStyle.padding.right = (int)(containerRect.width * labelHorPadding);

        // Set the textArea style
        txtAreaStyle                = activeSkin.textArea;
        txtAreaStyle.fontSize       = (int)(Screen.height * txtAreaFontScaling);
        txtAreaStyle.padding.top    = (int)(txtAreaStyle.fontSize * txtAreaTopPadding);
        txtAreaStyle.padding.bottom = (int)(txtAreaStyle.fontSize * txtAreaBtmPadding);

        // Set the radio button styles
        radioBtnStyle          = new GUIStyle(activeSkin.customStyles[2]);
        radioBtnStyle.fontSize = (int)(Screen.height * radioButtonFontScaling);
        var dimension = (int)(radioBtnStyle.fontSize * radioButtonSize);
        radioBtnStyle.fixedHeight  = dimension;
        radioBtnStyle.fixedWidth   = dimension;
        radioBtnStyle.margin.right = (int)((float)dimension * 0.25f);
        radioBtnStyle.margin.left  = (int)((float)dimension * 0.25f);

        // Set the button styles
        btnWidth  = Screen.width * 0.3f;
        btnHeight = btnWidth * ((float)activeSkin.button.normal.background.height /
                                (float)activeSkin.button.normal.background.width);

        // Font scaling
        activeSkin.button.fontSize = (int)(btnHeight * buttonFontScaling);
        // Padding Scaling
        activeSkin.button.padding.top = (int)(activeSkin.button.fontSize * buttonTopPadding);

        A_btnStyle = new GUIStyle(activeSkin.button);
        B_btnStyle = new GUIStyle(activeSkin.button);


        #region positioning

        // initialise variable to calculate total height
        float totalHeight = 0;
        float frameWidth  = Screen.width * innerFrameWidth;

        // header label
        labelHeight  = headerStyle.CalcHeight(new GUIContent(header), frameWidth);
        headerRect   = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight += labelHeight;

        // feedback 1 label
        labelHeight         = labelStyle.CalcHeight(new GUIContent(feedback_1), frameWidth);
        label_Feedback1Rect = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight        += labelHeight;

        // feedback 1 text area
        txtAreaHeight     = (txtAreaStyle.fontSize * fontHeightScale) * 3 + txtAreaStyle.padding.top + txtAreaStyle.padding.bottom;
        txtArea_Feedback1 = new Rect(0, totalHeight, frameWidth, txtAreaHeight);
        totalHeight      += txtAreaHeight;

        // feedback 2 label
        labelHeight         = labelStyle.CalcHeight(new GUIContent(feedback_2), frameWidth);
        label_Feedback2Rect = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight        += labelHeight;

        // feedback 2 text area
        txtAreaHeight     = (txtAreaStyle.fontSize * fontHeightScale) * 3 + txtAreaStyle.padding.top + txtAreaStyle.padding.bottom;
        txtArea_Feedback2 = new Rect(0, totalHeight, frameWidth, txtAreaHeight);
        totalHeight      += txtAreaHeight;

        // feedback 3 label
        labelHeight         = labelStyle.CalcHeight(new GUIContent(feedback_3), frameWidth);
        label_Feedback3Rect = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight        += labelHeight;

        // feedback 3 text area
        txtAreaHeight     = (txtAreaStyle.fontSize * fontHeightScale) * 3 + txtAreaStyle.padding.top + txtAreaStyle.padding.bottom;
        txtArea_Feedback3 = new Rect(0, totalHeight, frameWidth, txtAreaHeight);
        totalHeight      += txtAreaHeight;

        // feedback 4 label
        labelHeight         = labelStyle.CalcHeight(new GUIContent(feedback_4), frameWidth);
        label_Feedback4Rect = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight        += labelHeight;

        // feedback 4 text area
        txtAreaHeight     = (txtAreaStyle.fontSize * fontHeightScale) * 3 + txtAreaStyle.padding.top + txtAreaStyle.padding.bottom;
        txtArea_Feedback4 = new Rect(0, totalHeight, frameWidth, txtAreaHeight);
        totalHeight      += txtAreaHeight;

        // feedback 5 label
        labelHeight    = labelStyle.CalcHeight(new GUIContent(label_rate), frameWidth);
        label_RateRect = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight   += labelHeight;

        // radio button
        radioBtnRect = new Rect(0, totalHeight, frameWidth, dimension);
        totalHeight += dimension;

        // main menu and submit buttons
        A_btnRect    = new Rect(0, totalHeight, btnWidth, btnHeight);
        B_btnRect    = new Rect(frameWidth - btnWidth, totalHeight, btnWidth, btnHeight);
        totalHeight += btnHeight;

        // Initialise button scalers
        A_btnScale = new ButtonHandler(A_btnRect, gameObject, 0.9f, "A_ScaleButton");
        B_btnScale = new ButtonHandler(B_btnRect, gameObject, 0.9f, "B_ScaleButton");

        #endregion

        innerFrameRect   = new Rect(0, 0, frameWidth, totalHeight);
        innerFrameHeight = totalHeight;

        #endregion
    }
Пример #2
0
    void Start()
    {
        #if UNITY_EDITOR
        ServicePointManager.ServerCertificateValidationCallback = Validator;
        #endif

        // Connect to the app service
        serviceAPI = new ServiceAPI(Constants.apiKey, Constants.secretKey);

        // Build the log service
        logService = serviceAPI.BuildLogService();

        // Build Email Service
        emailService = serviceAPI.BuildEmailService();

        // Log the event
        logService.SetEvent("[DEMO] Contact", "Landed", logCallBack);
        #region GUI stuff
        containerRect = new Rect(Screen.width * ((1 - containerWidth) / 2),
                                 Screen.height * ((1 - containerHeight) / 2),
                                 Screen.width * containerWidth,
                                 Screen.height * containerHeight);

        // Set the header style
        headerStyle               = new GUIStyle(activeSkin.customStyles[0]);
        headerStyle.fontSize      = (int)(Screen.height * headerFontScaling);
        headerStyle.padding.left  = (int)(containerRect.width * labelHorPadding);
        headerStyle.padding.right = (int)(containerRect.width * labelHorPadding);

        // Set the label style
        labelStyle               = activeSkin.label;
        labelStyle.fontSize      = (int)(Screen.height * labelFontScaling);
        labelStyle.padding.left  = (int)(containerRect.width * labelHorPadding);
        labelStyle.padding.right = (int)(containerRect.width * labelHorPadding);

        // set the error msg style
        alertMsgStyle               = new GUIStyle(activeSkin.customStyles[1]);
        alertMsgStyle.fontSize      = labelStyle.fontSize;
        alertMsgStyle.padding.left  = (int)(containerRect.width * labelHorPadding);
        alertMsgStyle.padding.right = (int)(containerRect.width * labelHorPadding);

        // Set the textArea style
        txtAreaStyle                = activeSkin.textArea;
        txtAreaStyle.fontSize       = (int)(Screen.height * txtAreaFontScaling);
        txtAreaStyle.padding.top    = (int)(txtAreaStyle.fontSize * txtAreaTopPadding);
        txtAreaStyle.padding.bottom = (int)(txtAreaStyle.fontSize * txtAreaBtmPadding);

        // Set the button styles
        btnWidth  = Screen.width * 0.3f;
        btnHeight = btnWidth * ((float)activeSkin.button.normal.background.height /
                                (float)activeSkin.button.normal.background.width);

        // Font scaling
        activeSkin.button.fontSize = (int)(btnHeight * buttonFontScaling);
        // Padding Scaling
        activeSkin.button.padding.top = (int)(activeSkin.button.fontSize * buttonTopPadding);

        A_btnStyle = new GUIStyle(activeSkin.button);
        B_btnStyle = new GUIStyle(activeSkin.button);

        // Calculate positions
        #region positioning

        // initialise variable to calculate total height
        float totalHeight = 0;
        float frameWidth  = Screen.width * innerFrameWidth;

        // header label
        labelHeight  = headerStyle.fontSize * fontHeightScale + headerStyle.padding.top + headerStyle.padding.bottom;
        headerRect   = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight += labelHeight;

        // name label
        labelHeight    = labelStyle.fontSize * fontHeightScale + labelStyle.padding.top + labelStyle.padding.bottom;
        label_NameRect = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight   += labelHeight;

        // sender's name
        txtAreaHeight    = txtAreaStyle.fontSize * fontHeightScale + txtAreaStyle.padding.top + txtAreaStyle.padding.bottom;
        txtArea_NameRect = new Rect(0, totalHeight, frameWidth, txtAreaHeight);
        totalHeight     += txtAreaHeight;

        // email label
        labelHeight     = labelStyle.fontSize * fontHeightScale + labelStyle.padding.top + labelStyle.padding.bottom;
        label_EmailRect = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight    += labelHeight;

        // sender's email
        txtAreaHeight     = txtAreaStyle.fontSize * fontHeightScale + txtAreaStyle.padding.top + txtAreaStyle.padding.bottom;
        txtArea_EmailRect = new Rect(0, totalHeight, frameWidth, txtAreaHeight);
        totalHeight      += txtAreaHeight;

        // email subject label
        labelHeight            = labelStyle.fontSize * fontHeightScale + labelStyle.padding.top + labelStyle.padding.bottom;
        label_EmailSubjectRect = new Rect(0, totalHeight, frameWidth, labelHeight);
        totalHeight           += labelHeight;

        // email subject
        txtAreaHeight            = txtAreaStyle.fontSize * fontHeightScale + txtAreaStyle.padding.top + txtAreaStyle.padding.bottom;
        txtArea_EmailSubjectRect = new Rect(0, totalHeight, frameWidth, txtAreaHeight);
        totalHeight += txtAreaHeight;

        // email body
        txtAreaHeight         = (txtAreaStyle.fontSize * fontHeightScale) * 5 + txtAreaStyle.padding.top + txtAreaStyle.padding.bottom;
        txtArea_EmailBodyRect = new Rect(0, totalHeight, frameWidth, txtAreaHeight);
        totalHeight          += txtAreaHeight;

        // main menu and submit buttons
        A_btnRect    = new Rect(0, totalHeight, btnWidth, btnHeight);
        B_btnRect    = new Rect(frameWidth - btnWidth, totalHeight, btnWidth, btnHeight);
        totalHeight += btnHeight;


        // Initialise button scalers
        A_btnScale = new ButtonHandler(A_btnRect, gameObject, 0.9f, "A_ScaleButton");
        B_btnScale = new ButtonHandler(B_btnRect, gameObject, 0.9f, "B_ScaleButton");


        #endregion

        innerFrameRect   = new Rect(0, 0, frameWidth, totalHeight);
        innerFrameHeight = totalHeight;

        #endregion
    }
Пример #3
0
    void Awake()
    {
        #region App42

        #if UNITY_EDITOR
        ServicePointManager.ServerCertificateValidationCallback = Validator;
        #endif

        // Connect to the app service
        serviceAPI = new ServiceAPI(Constants.apiKey, Constants.secretKey);

        // Build the log service
        logService = serviceAPI.BuildLogService();

        // Build the storage service
        storageService = serviceAPI.BuildStorageService();

        // Log the event
        logService.SetEvent("[DEMO] Title Screen", "Landed", logCallBack);
        logService.SetEvent("[DEMO] Title Screen", logCallBack);

        #endregion

        #region GUI
        logoContainerWidth  = Screen.width * 0.6f;
        logoContainerHeight = Screen.height;
        logoContainerRect   = new Rect(0, 0, logoContainerWidth, logoContainerHeight);

        logoTexture = activeSkin.customStyles[0].normal.background;
        logoWidth   = logoContainerWidth;
        logoHeight  = logoWidth * ((float)logoTexture.height / (float)logoTexture.width);
        logoXOffset = 0;
        logoYOffset = 0;
        logoRect    = new Rect(logoXOffset, logoYOffset, logoWidth, logoHeight);

        // Font auto scaling
        activeSkin.label.fontSize = (int)(Screen.height * demoTextFontScale);
        demoTextRect = new Rect(0, logoHeight * 0.8f, logoContainerWidth, activeSkin.label.fontSize * 2);

        navContainerWidth   = Screen.width * 0.3f;
        navContainerXOffset = logoContainerWidth;

        btnWidth  = navContainerWidth;
        btnHeight = navContainerWidth * ((float)activeSkin.button.normal.background.height /
                                         (float)activeSkin.button.normal.background.width);

        navContainerHeight  = btnHeight * 5;
        navContainerYOffset = (Screen.height - navContainerHeight) * 0.5f;

        navContainerRect = new Rect(navContainerXOffset, navContainerYOffset, navContainerWidth, navContainerHeight);
        A_btnRect        = new Rect(0, 0, btnWidth, btnHeight);
        B_btnRect        = new Rect(0, btnHeight, btnWidth, btnHeight);
        C_btnRect        = new Rect(0, btnHeight * 2, btnWidth, btnHeight);
        D_btnRect        = new Rect(0, btnHeight * 3, btnWidth, btnHeight);
        E_btnRect        = new Rect(0, btnHeight * 4, btnWidth, btnHeight);

        // Initialise button scalers
        A_btnScale = new ButtonHandler(A_btnRect, gameObject, 0.9f, "A_ScaleButton");
        B_btnScale = new ButtonHandler(B_btnRect, gameObject, 0.9f, "B_ScaleButton");
        C_btnScale = new ButtonHandler(C_btnRect, gameObject, 0.9f, "C_ScaleButton");
        D_btnScale = new ButtonHandler(D_btnRect, gameObject, 0.9f, "D_ScaleButton");
        E_btnScale = new ButtonHandler(E_btnRect, gameObject, 0.9f, "E_ScaleButton");

        // Nav button font scaling
        activeSkin.button.fontSize = (int)(btnHeight * navFontScaling);
        // Padding Scaling
        activeSkin.button.padding.top    = (int)(activeSkin.button.fontSize * navTopPaddingScaling);
        activeSkin.button.padding.bottom = (int)(activeSkin.button.fontSize * navBottomPaddingScaling);
        // Set the styles
        A_btnStyle = new GUIStyle(activeSkin.button);
        B_btnStyle = new GUIStyle(activeSkin.button);
        C_btnStyle = new GUIStyle(activeSkin.button);
        D_btnStyle = new GUIStyle(activeSkin.button);
        E_btnStyle = new GUIStyle(activeSkin.button);
        #endregion
    }
Пример #4
0
    void OnGUI()
    {
        if (Time.time % 2 < 1)
        {
            success = callBack.getResult();
        }

        // For Setting Up ResponseBox.
        GUI.TextArea(new Rect(10, 5, 1300, 175), success);


        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(50, 200, 200, 30), "Info"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.Info(msg, module, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(260, 200, 200, 30), "Debug"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.Debug(msg, module, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(470, 200, 200, 30), "Fatal"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.Fatal(msg, module, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(680, 200, 200, 30), "Error"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.Error(msg, module, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(890, 200, 200, 30), "FetchLogsByModule"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByModule(module, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(50, 250, 200, 30), "FetchLogsByModuleAndText"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByModuleAndText(module, text, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(260, 250, 200, 30), "SetEvent"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.SetEvent(eventName, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(470, 250, 200, 30), "FetchLogsByInfo"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByInfo(callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(680, 250, 200, 30), "FetchLogsByDebug"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByDebug(callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(890, 250, 200, 30), "FetchLogsByError"))
        {
            App42Log.SetDebug(true);
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByError(callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(50, 300, 200, 30), "FetchLogsByFatal"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByFatal(callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(260, 300, 200, 30), "FetchLogByDateRange"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogByDateRange(startDate, endDate, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(470, 300, 200, 30), "FetchLogsByInfoByPaging"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByInfo(max, offSet, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(680, 300, 200, 30), "FetchLogsByDebugByPaging"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByDebug(max, offSet, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(890, 300, 200, 30), "FetchLogsByErrorByPaging"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByError(max, offSet, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(50, 350, 200, 30), "FetchLogsByFatalByPaging"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByFatal(max, offSet, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(260, 350, 200, 30), "FetchLogsByModuleByPaging"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByModule(module, max, offSet, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(470, 350, 200, 30), "FetchLogsByModuleAndTextByPaging"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsByModuleAndText(module, text, max, offSet, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(680, 350, 200, 30), "FetchLogByDateRangeByPaging"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogByDateRange(startDate, endDate, max, offSet, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(890, 350, 200, 30), "FetchLogsCountByModule"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsCountByModule(module, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(50, 400, 200, 30), "FetchLogsCountByModuleAndText"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsCountByModuleAndText(module, text, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(260, 400, 200, 30), "FetchLogsCountByInfo"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsCountByInfo(callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(470, 400, 200, 30), "FetchLogsCountByDebug"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsCountByDebug(callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(680, 400, 200, 30), "FetchLogsCountByError"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsCountByError(callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(890, 400, 200, 30), "FetchLogsCountByFatal"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogsCountByFatal(callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(50, 450, 200, 30), "FetchLogCountByDateRange"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.FetchLogCountByDateRange(startDate, endDate, callBack);
        }

        //=======================================LOG_SERVICE=======================================

        if (GUI.Button(new Rect(260, 450, 200, 30), "SetEvent"))
        {
            logService = sp.BuildLogService();              // Initializing Log Service.
            logService.SetEvent(module, eventName, callBack);
        }
    }