Inheritance: UnityEngine.EventSystems.UIBehaviour
    void Awake()
    {
        scaler = GetComponent<CanvasScaler>();
        scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;

        
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        //Creates a reference to the canvas scaler
        scaler = GetComponent<CanvasScaler>();

        //Makes the canvas scale with the screensize
        scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
    }
 void Start()
 {
     cs = GetComponent<UIManager>().UI.GetComponent<CanvasScaler>();
     if (doChangeResolution)
     {
         StartCoroutine (ChangeREsolution ());
     }
     if (doCap) { Application.targetFrameRate = frameRate; }
 }
Example #4
0
        /// <summary>
        /// 创建Canvas
        /// </summary>
        /// <param name="uiSize"></param>
        /// <returns></returns>
        public static Canvas CreateCanvas(Vector2 uiSize)
        {
            var canvas = new GameObject("Canvas", typeof(Canvas), typeof(RectTransform), typeof(CanvasScaler), typeof(GraphicRaycaster)).GetComponent <Canvas>();

            UnityEngine.UI.CanvasScaler scaler = canvas.GetComponent <UnityEngine.UI.CanvasScaler>();
            scaler.uiScaleMode         = CanvasScaler.ScaleMode.ScaleWithScreenSize;
            canvas.renderMode          = RenderMode.ScreenSpaceOverlay;
            scaler.referenceResolution = new Vector2(uiSize.x, uiSize.y);
            return(canvas);
        }
 void Start()
 {
     scaler = GetComponent<CanvasScaler>();
     scaler.scaleFactor = ScreenDPICalculator.userInterfaceScale;
     dpiText.text = "DPI: " + Screen.dpi + "    Scale Factor: " + scaler.scaleFactor;
     if (Debug.isDebugBuild)
     {
         Debug.Log("DPI: " + Screen.dpi + "    Scale Factor: " + scaler.scaleFactor);
     }
 }
Example #6
0
 static public int set_fallbackScreenDPI(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.fallbackScreenDPI = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #7
0
 static public int set_uiScaleMode(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler           self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         UnityEngine.UI.CanvasScaler.ScaleMode v;
         checkEnum(l, 2, out v);
         self.uiScaleMode = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #8
0
 static public int set_physicalUnit(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler      self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         UnityEngine.UI.CanvasScaler.Unit v;
         checkEnum(l, 2, out v);
         self.physicalUnit = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #9
0
 static public int set_matchWidthOrHeight(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.matchWidthOrHeight = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #10
0
 static public int set_referenceResolution(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         UnityEngine.Vector2         v;
         checkType(l, 2, out v);
         self.referenceResolution = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #11
0
 static public int set_screenMatchMode(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         UnityEngine.UI.CanvasScaler.ScreenMatchMode v;
         checkEnum(l, 2, out v);
         self.screenMatchMode = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_scaleFactor(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.scaleFactor = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #13
0
    protected override void Awake()
    {
        base.Awake();
        _v2HidePos = Vector2.one * 50000;

        _mainCam = CameraManager.Instance.MainCamera;
        UnityEngine.UI.CanvasScaler canvasScaler2dUI = DoozyUI.UIManager.GetUiContainer.GetComponent <UnityEngine.UI.CanvasScaler>();
        _fMatchRatio     = canvasScaler2dUI.matchWidthOrHeight;
        _fResolutionFixX = canvasScaler2dUI.referenceResolution.x / (float)_mainCam.pixelWidth;
        _fResolutionFixY = canvasScaler2dUI.referenceResolution.y / (float)_mainCam.pixelHeight;

        _animHand   = imgHand.GetComponent <Animator>();
        _animRotate = imgAround.GetComponent <Animator>();
    }
 static public int set_screenMatchMode(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         UnityEngine.UI.CanvasScaler.ScreenMatchMode v;
         checkEnum(l, 2, out v);
         self.screenMatchMode = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #15
0
 static public int set_scaleFactor(IntPtr l)
 {
     try {
         UnityEngine.UI.CanvasScaler self = (UnityEngine.UI.CanvasScaler)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.scaleFactor = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #16
0
    void Awake()
    {
        //! Canvas.
        canvas = gameObject.AddComponent<Canvas>();
        canvas.renderMode = RenderMode.ScreenSpaceOverlay;
        canvas.sortingOrder = sysMsgOrder;
        canvasScaler = gameObject.AddComponent<CanvasScaler>();
        canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
        canvasScaler.referenceResolution = screenResolution;
        canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
        canvasScaler.matchWidthOrHeight = 1.0f;
        canvasScaler.referencePixelsPerUnit = 100.0f;

        //! Fps.
        GameObject fpsGo = new GameObject("Fps");
        fpsGo.transform.parent = transform;
        fpsGo.AddComponent<CanvasRenderer>();
        fpsText = fpsGo.AddComponent<Text>();
        font = Resources.GetBuiltinResource<Font>("Arial.ttf");
        fpsText.font = font;
        fpsText.fontSize = 46;
        fpsText.alignment = TextAnchor.MiddleRight;
        RectTransform rect = fpsGo.GetComponent<RectTransform>();
        rect.localPosition = new Vector3(-250.0f, -40.0f, 0.0f);
        rect.sizeDelta = new Vector2( 457.0f, 135.0f);
        fpsGo.AddComponent<FPS>();

        // top and right.
        fpsGo.GetComponent<RectTransform>().anchorMin = new Vector2(1, 1);
        fpsGo.GetComponent<RectTransform>().anchorMax = new Vector2(1, 1);

        //! memeory.
        GameObject memGo = new GameObject("Memory");
        memGo.transform.parent = transform;
        memGo.AddComponent<CanvasRenderer>();
        memoryText = memGo.AddComponent<Text>();
        memoryText.font = font;
        memoryText.fontSize = 46;
        memoryText.alignment = TextAnchor.MiddleRight;
        rect = memGo.GetComponent<RectTransform>();
        rect.localPosition = new Vector3(-250.0f, -120.0f, 0.0f);
        rect.sizeDelta = new Vector2(457.0f, 135.0f);
        memGo.AddComponent<Memory>();

        // top and right.
        memGo.GetComponent<RectTransform>().anchorMin = new Vector2(1, 1);
        memGo.GetComponent<RectTransform>().anchorMax = new Vector2(1, 1);
    }
Example #17
0
    private void CreateRootCanvas()
    {
        m_objRootCanvas = new GameObject();
        m_objRootCanvas.name = "RootCanvas";
        m_objRootCanvas.layer = GameLayer.UI;
        m_transRootCanvas = m_objRootCanvas.AddComponent<RectTransform>();
        m_compRootCanvas = m_objRootCanvas.AddComponent<Canvas>();
        m_compRootCanvasScaler = m_objRootCanvas.AddComponent<CanvasScaler>();
        m_compRootGraphicRaycaster = m_objRootCanvas.AddComponent<GraphicRaycaster>();
        m_compTicker = m_objRootCanvas.AddComponent<Ticker>();
        m_compTicker.onUpdate += OnTryOpenBufferedWindow;
        GameObject.DontDestroyOnLoad(m_objRootCanvas);

        m_compRootCanvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
        m_compRootCanvasScaler.referenceResolution = new Vector2(1920, 1080);
    }
Example #18
0
	public virtual void Awake(){
		
		cachedTransform = this.rectTransform();
		cachedCanvasGroup = GetComponent<CanvasGroup>();
		cachedCanvasScaler = GetComponentInParent<CanvasScaler>();
		if (cachedCanvasScaler!=null){
			//Debug.LogWarning("Canvas scaler is missing");

			startTransform.InitAllFromRectTransform( cachedTransform, alpha);

			// Helper
			originOffset = GetOriginOffset(startTransform.anchorMin);

			EMMotionManager.instance.RegisterMotion( this);
		}
	}	
    static int get_scaleFactor(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            float ret = obj.scaleFactor;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index scaleFactor on a nil value"));
        }
    }
    static int get_uiScaleMode(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler           obj = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.UI.CanvasScaler.ScaleMode ret = obj.uiScaleMode;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index uiScaleMode on a nil value"));
        }
    }
    static int set_dynamicPixelsPerUnit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.dynamicPixelsPerUnit = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index dynamicPixelsPerUnit on a nil value"));
        }
    }
    static int set_fallbackScreenDPI(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.fallbackScreenDPI = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index fallbackScreenDPI on a nil value"));
        }
    }
    static int set_physicalUnit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler      obj  = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.UI.CanvasScaler.Unit arg0 = (UnityEngine.UI.CanvasScaler.Unit)ToLua.CheckObject(L, 2, typeof(UnityEngine.UI.CanvasScaler.Unit));
            obj.physicalUnit = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index physicalUnit on a nil value"));
        }
    }
    static int set_screenMatchMode(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.UI.CanvasScaler.ScreenMatchMode arg0 = (UnityEngine.UI.CanvasScaler.ScreenMatchMode)ToLua.CheckObject(L, 2, typeof(UnityEngine.UI.CanvasScaler.ScreenMatchMode));
            obj.screenMatchMode = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index screenMatchMode on a nil value"));
        }
    }
    static int get_physicalUnit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler      obj = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.UI.CanvasScaler.Unit ret = obj.physicalUnit;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index physicalUnit on a nil value" : e.Message));
        }
    }
    static int get_referenceResolution(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.Vector2         ret = obj.referenceResolution;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index referenceResolution on a nil value"));
        }
    }
Example #27
0
    static int set_uiScaleMode(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler           obj  = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.UI.CanvasScaler.ScaleMode arg0 = (UnityEngine.UI.CanvasScaler.ScaleMode)LuaDLL.luaL_checknumber(L, 2);
            obj.uiScaleMode = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index uiScaleMode on a nil value"));
        }
    }
    static int get_referencePixelsPerUnit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            float ret = obj.referencePixelsPerUnit;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index referencePixelsPerUnit on a nil value" : e.Message));
        }
    }
    static int set_defaultSpriteDPI(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.defaultSpriteDPI = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index defaultSpriteDPI on a nil value" : e.Message));
        }
    }
    static int get_defaultSpriteDPI(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            float ret = obj.defaultSpriteDPI;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index defaultSpriteDPI on a nil value" : e.Message));
        }
    }
Example #31
0
    static int get_screenMatchMode(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.UI.CanvasScaler.ScreenMatchMode ret = obj.screenMatchMode;
            LuaDLL.lua_pushinteger(L, (int)ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index screenMatchMode on a nil value"));
        }
    }
Example #32
0
    static int get_physicalUnit(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler      obj = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.UI.CanvasScaler.Unit ret = obj.physicalUnit;
            LuaDLL.lua_pushinteger(L, (int)ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index physicalUnit on a nil value"));
        }
    }
    static int get_screenMatchMode(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.UI.CanvasScaler.ScreenMatchMode ret = obj.screenMatchMode;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index screenMatchMode on a nil value" : e.Message));
        }
    }
        public void Update()
        {
            if (!scaler)
                scaler = gameObject.GetComponent<CanvasScaler>();

            if (scaler.uiScaleMode == CanvasScaler.ScaleMode.ScaleWithScreenSize)
            {
                referenceResolution = scaler.referenceResolution;
                currentResolution = new Vector2(Screen.width, Screen.height);

                scaleFactor = (currentResolution.x*currentResolution.y)/(referenceResolution.x*referenceResolution.y);
            }
            else if (scaler.uiScaleMode == CanvasScaler.ScaleMode.ConstantPixelSize)
            {
                scaleFactor = scaler.scaleFactor;
            }
        }
    static int set_referenceResolution(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.CanvasScaler obj  = (UnityEngine.UI.CanvasScaler)o;
            UnityEngine.Vector2         arg0 = ToLua.ToVector2(L, 2);
            obj.referenceResolution = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index referenceResolution on a nil value"));
        }
    }
    void Start()
    {
        help = FindObjectOfType <HelpController> ();
        rt   = root.GetComponent <RectTransform> ();
        UnityEngine.UI.CanvasScaler cnv = rt.root.GetComponent <UnityEngine.UI.CanvasScaler> ();
        float canvasRatio = Mathf.Lerp(cnv.referenceResolution.x, cnv.referenceResolution.y, cnv.matchWidthOrHeight);
        float screenRatio = Mathf.Lerp(Screen.width, Screen.height, cnv.matchWidthOrHeight);

        scaleRatio = canvasRatio / screenRatio;

        character = target.GetComponent <CharacterScript>();

        if (root)
        {
            root.SetActive(false);
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        pdfCanvas       = GetComponent <Canvas>();
        positionVectors = pdfCanvas.transform.position;
        c            = GetComponent <UnityEngine.UI.CanvasScaler>();
        scaleVectors = pdfCanvas.transform.localScale;

        //Determines of the canvas object was succesfully found
        if (pdfCanvas != null)
        {
            Debug.Log("Canvas Found!");
        }
        else
        {
            Debug.Log("Canvas Not Found!");
        }
    }
Example #38
0
        // Use this for initialization
        void Start()
        {
            setupBtn2();
            MainText.color   = Color.green;
            profileName.text = WorldConnection2.ourPlayerName;
            TargetBox.SetActive(false);

                #if UNITY_EDITOR || UNITY_WEBGL || UNITY_STANDALONE
            DesktopPanel.SetActive(true);
                #endif

                #if UNITY_IOS || UNITY_ANDROID || UNITY_WP_8_1
            MobilePanel.SetActive(true);
            UnityEngine.UI.CanvasScaler c = GetComponent <UnityEngine.UI.CanvasScaler>();
            c.uiScaleMode         = UnityEngine.UI.CanvasScaler.ScaleMode.ScaleWithScreenSize;
            c.referenceResolution = new Vector2(960, 540);
                #endif
        }
	// Use this for initialization
	void Start () {



		if (game_master.game_master_obj)
			{
			my_game_master = (game_master)game_master.game_master_obj.GetComponent("game_master");
			my_gift_manager.my_game_master = my_game_master;
			//play music menu again
			my_game_master.music_source.enabled  = true;
			if (my_game_master.my_ads_master)
				{
				my_game_master.my_ads_master.my_feedback_window = my_feedback_window;
				my_game_master.my_ads_master.my_gift_manager = my_gift_manager;
				my_game_master.my_ads_master.my_info_bar = info_bar;
				}
			score_ranck_ico.SetActive(true);
//			score_ranck_ico.SetActive(my_game_master.show_int_score_rank);

			if (my_game_master.my_ads_master.enable_ads)
				Check_internet();
			else
				internet_off_ico.SetActive(false); 
			}


		this_script = this.gameObject.GetComponent("manage_menu_uGUI") as manage_menu_uGUI;
		my_options = options_screen.GetComponent<options_menu>();

		//adjust canvas scale
		my_scale = this.gameObject.GetComponent<CanvasScaler>();
		if (my_scale)
			{
			if (my_game_master.press_start_and_go_to_selected == game_master.press_start_and_go_to.map)
				my_scale.matchWidthOrHeight = 0.7f;
			else 
				my_scale.matchWidthOrHeight = 0.75f;
			}

		//stage pages
		stages_screen_manual = new Transform[manual_stage_screens_list.childCount];
		for (int i = 0; i < stages_screen_manual.Length; i++)
			stages_screen_manual[i] = manual_stage_screens_list.GetChild(i);

		Setup_stage_page();


		if (my_game_master.press_start_and_go_to_selected == game_master.press_start_and_go_to.nested_world_stage_select_screen)
			{
			if (my_game_master.total_stages_in_world_n.Length == 1)
				{
				if(my_game_master.stage_screen_generation_selected == game_master.stage_screen_generation.automatic)
					{
					Generate_stage_screen(my_game_master.current_world[my_game_master.current_profile_selected]);
					}

				}
			else
				{
				if (my_game_master.world_screen_generation_selected == game_master.world_screen_generation.automatic)
					Generate_world_screen();
				else if (my_game_master.world_screen_generation_selected == game_master.world_screen_generation.manual)
					my_manual_world_screen.My_start();
				}
			}

		info_bar.Show_info_bar(false);

		if (my_game_master.go_to_this_screen == game_master.this_screen.home_screen)//is this scene not is load from a game stage
		{

			//show logo at the start
			if (logo_screen != null && show_logo_for_n_seconds > 0 && !game_master.logo_already_show)
				{
				Mark_current_screen(logo_screen);
				home_screen.gameObject.SetActive(false);
				game_master.logo_already_show = true;

				if (!my_game_master.show_new_profile_window)
					{
					Update_profile_name(true);
					}
				Invoke("Close_logo",show_logo_for_n_seconds);
				}
			else//don't show logo at the start
				{
				if (!game_master.logo_already_show)
					{
					game_master.logo_already_show = true;
					if (!my_game_master.show_new_profile_window)
						{
						Update_profile_name(true);
						if (my_game_master.my_ads_master.Check_app_start_ad_countdown())
							my_game_master.my_ads_master.Call_ad(my_game_master.my_ads_master.ads_just_after_logo_when_game_start_as_daily_reward);
						}
					}
				//start music when the game start
				my_game_master.Start_music(my_game_master.music_menu,true);
				Show_home_screen();
				}
		}
		else if (my_game_master.go_to_this_screen == game_master.this_screen.stage_screen) //return to home stage from a game stage
		{
			if (my_game_master.show_debug_messages)
				Debug.Log("return to home stage from a game stage");

			home_screen.gameObject.SetActive(false);
			//Update_profile_name(true);
			if (my_game_master.press_start_and_go_to_selected == game_master.press_start_and_go_to.nested_world_stage_select_screen)
				{
				if(my_game_master.stage_screen_generation_selected == game_master.stage_screen_generation.automatic)
					{
					Mark_current_screen(stages_screen_automatic);

					Generate_stage_screen(my_game_master.current_world[my_game_master.current_profile_selected]);

					Mark_this_button(stage_screen_target_button);
					}
				else if (my_game_master.stage_screen_generation_selected == game_master.stage_screen_generation.manual)
					{
					Mark_current_screen(stages_screen_manual[my_game_master.current_world[my_game_master.current_profile_selected]]);
					}
				}
			else if (my_game_master.press_start_and_go_to_selected == game_master.press_start_and_go_to.map)
				{
				Mark_current_screen(map_screen);
				}
			else if (my_game_master.press_start_and_go_to_selected == game_master.press_start_and_go_to.single_screen_with_a_page_for_every_world)
				{
				Mark_current_screen(multi_page_screen);
				}
			else if (my_game_master.press_start_and_go_to_selected == game_master.press_start_and_go_to.straight_to_the_next_game_stage)
				{
				Mark_current_screen(home_screen);
				}

			Update_profile_name(true);

			my_game_master.my_ads_master.Call_ad(my_game_master.my_ads_master.ads_when_return_to_home_scene_from_a_stage);

			//start music when retur to home from a game stage
			my_game_master.Start_music(my_game_master.music_menu,true);

		}
	}
Example #40
0
    /// <summary>
    /// Set UI Component.
    /// </summary>
    void SetUIComponent()
    {
        //! Canvas.
        canvas = gameObject.AddComponent<Canvas>();
        canvas.renderMode = RenderMode.ScreenSpaceOverlay;
        canvas.sortingOrder = sysMsgOrder;
        canvasScaler = gameObject.AddComponent<CanvasScaler>();
        canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
        canvasScaler.referenceResolution = screenResolution;
        canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
        canvasScaler.matchWidthOrHeight = 1.0f;
        canvasScaler.referencePixelsPerUnit = 100.0f;
        font = Resources.GetBuiltinResource<Font>("Arial.ttf");
        RectTransform rect;

        //! Credit.
        GameObject creditGO = new GameObject("Credit");
        creditGO.transform.parent = transform;
        creditGO.AddComponent<CanvasRenderer>();
        creditText = creditGO.AddComponent<Text>();
        creditText.font = font;
        creditText.fontSize = 38;
        creditText.alignment = TextAnchor.MiddleCenter;
        RefreshCreditText();
        rect = creditGO.GetComponent<RectTransform>();
        rect.localPosition = new Vector3(0.0f, 70.0f, 0.0f);
        rect.sizeDelta = new Vector2(457.0f, 135.0f);

        // bottom and center.
        creditGO.GetComponent<RectTransform>().anchorMin = new Vector2(0.5f, 0f);
        creditGO.GetComponent<RectTransform>().anchorMax = new Vector2(0.5f, 0f);
    }
 private void Start()
 {
     canvasScaler = GetComponent<CanvasScaler>();
 }
Example #42
0
 // Use this for initialization
 void Start()
 {
     _canvas = GameObject.Find ("BuildingUi").GetComponent<BuildingUiCanvas> ();
     _scale = GameObject.Find ("BuildingNeedsAndProduction").GetComponent<CanvasScaler> ();
 }
    void Start()
    {
        scaler = GetComponent<CanvasScaler>();

        scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
    }
 void Start()
 {
     canvasScaler = transform.GetComponentInParent<CanvasScaler>();
     self = GetComponent<RectTransform>();
 }
Example #45
0
        public void Awake()
        {
            if (FindObjectsOfType<GameManager>().Length > 1)
            {
                Destroy(gameObject);
            }
            else
            {
                GameManager.instance = this;
            }

            AudioListener.volume = PlayerPrefs.GetFloat("AudioVolume", 1);
            DontDestroyOnLoad(this);
            Instantiate(Resources.Load("Prefabs/AudioManager"));
            LanguageManager.Instance.ChangeLanguage(Language);
            LanguageManager.Instance.name = "Language Manager";
            LanguageManager.Instance.transform.SetParent(transform, false);
            OnLevelWasLoaded(SceneManager.GetActiveScene().buildIndex);

            this.canvas = GetComponent<Canvas>();
            this.canvasScaler = GetComponent<CanvasScaler>();
            this.fader = new GameObject("Transition Fader", typeof(Image)).GetComponent<Image>();
            this.loadingScreen = new GameObject("Loading Screen", typeof(Image)).GetComponent<Image>();
            this.loadingSpriteA = Resources.Load<Sprite>("UI/LoadingScreenLoading");
            this.loadingSpriteB = Resources.Load<Sprite>("UI/LoadingScreenDone");
        }
    /*
    For more information on the OnInspectorGUI and adding your own variables
    in the UltimateJoystick.cs script and displaying them in this script,
    see the EditorGUILayout section in the Unity Documentation to help out.
    */
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        // Store the joystick that we are selecting
        UltimateJoystick uj = ( UltimateJoystick )target;

        #region ERROR CHECKING
        /* ---------------------------------------- > ERROR CHECKING < ---------------------------------------- */
        if( canvasRect == null )
        {
            if( uj.transform.root.GetComponent<CanvasScaler>() )
                canvasRect = uj.transform.root.GetComponent<CanvasScaler>();
            else
                canvasRect = GetParentCanvas( uj );
        }
        if( canvasRect != null && canvasRect.uiScaleMode != CanvasScaler.ScaleMode.ConstantPixelSize )
        {
            EditorGUILayout.BeginVertical( "Button" );
            EditorGUILayout.HelpBox( "The Ultimate Joystick cannot be used correctly because the root canvas is using " + canvasRect.uiScaleMode.ToString() + ". Please place the Ultimate Joystick into a different Canvas with the ConstantPixelSize option.", MessageType.Error );
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if( GUILayout.Button( "Adjust Canvas", GUILayout.Width( 100 ), GUILayout.Height( 20 ) ) )
            {
                Debug.Log( "CanvasScaler / ScaleMode option has been adjusted." );
                canvasRect.uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize;
            }
            GUILayout.FlexibleSpace();
            if( GUILayout.Button( "Adjust Joystick", GUILayout.Width( 100 ), GUILayout.Height( 20 ) ) )// 75
            {
                bool canvasExists = false;
                Transform targetCanvas = uj.transform;
                CanvasScaler[] allCanvas = GameObject.FindObjectsOfType<CanvasScaler>();
                foreach( CanvasScaler currCanvas in allCanvas )
                {
                    if( canvasExists == false )
                    {
                        if( currCanvas.uiScaleMode == CanvasScaler.ScaleMode.ConstantPixelSize )
                        {
                            canvasExists = true;
                            targetCanvas = currCanvas.transform;
                        }
                    }
                }
                // If we didn't find a Canvas with the right options, then we need to make one
                if( canvasExists == false )
                {
                    // For full comments, please refer to CreateJoystickEditor.cs
                    Debug.Log( "Ultimate UI Canvas has been created." );
                    GameObject root = new GameObject( "Ultimate UI Canvas" );
                    root.layer = LayerMask.NameToLayer( "UI" );
                    Canvas canvas = root.AddComponent<Canvas>();
                    canvas.renderMode = RenderMode.ScreenSpaceOverlay;
                    root.AddComponent<CanvasScaler>();
                    root.AddComponent<GraphicRaycaster>();
                    Undo.RegisterCreatedObjectUndo( root, "Create " + root.name );
                    targetCanvas = root.transform;
                }

                // Here we set the joystick to be a child of the canvas
                uj.transform.SetParent( targetCanvas.transform, false );

                // Focus on the moved Ultimate Joystick gameObject
                Selection.activeGameObject = uj.gameObject;

                // Tell the user
                Debug.Log( "Ultimate Joystick has been relocated to Ultimate UI Canvas." );

                canvasRect = null;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            return;
        }
        /* ---------------------------------------- > END ERROR CHECKING < ---------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region ASSIGNED VARIABLES
        /* ---------------------------------------- > ASSIGNED VARIABLES < ---------------------------------------- */
        EditorGUILayout.BeginVertical( "Toolbar" );
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField( "Assigned Variables", EditorStyles.boldLabel );
        string v_option = "Show";
        if( EditorPrefs.GetBool( "UUI_Variables" ) == true )
            v_option = "Hide";
        if( GUILayout.Button( v_option, EditorStyles.miniButton, GUILayout.Width( 50 ), GUILayout.Height( 14f ) ) )
        {
            if( EditorPrefs.GetBool( "UUI_Variables" ) == true )
                EditorPrefs.SetBool( "UUI_Variables", false );
            else
                EditorPrefs.SetBool( "UUI_Variables", true );
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        if( EditorPrefs.GetBool( "UUI_Variables" ) == true )
        {
            EditorGUILayout.Space();
            EditorGUI.indentLevel = 1;
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( joystick );
            EditorGUILayout.PropertyField( joystickSizeFolder, new GUIContent( "Size Folder" ) );
            EditorGUI.indentLevel = 0;
            if( uj.showHighlight == true )
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField( "Highlight Variables", EditorStyles.boldLabel );
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField( highlightBase );
                EditorGUILayout.PropertyField( highlightJoystick );
                EditorGUI.indentLevel = 0;
            }
            if( uj.showTension == true )
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField( "Tension Variables", EditorStyles.boldLabel );
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField( tensionAccentUp, new GUIContent( "Tension Up" ) );
                EditorGUILayout.PropertyField( tensionAccentDown, new GUIContent( "Tension Down" ) );
                EditorGUILayout.PropertyField( tensionAccentLeft, new GUIContent( "Tension Left" ) );
                EditorGUILayout.PropertyField( tensionAccentRight, new GUIContent( "Tension Right" ) );
                EditorGUI.indentLevel = 0;
            }
            if( uj.useAnimation || uj.useFade == true )
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField( "Touch Action Variables", EditorStyles.boldLabel );
                EditorGUI.indentLevel = 1;
                if( uj.useAnimation == true )
                    EditorGUILayout.PropertyField( joystickAnimator );
                if( uj.useFade == true )
                    EditorGUILayout.PropertyField( joystickBase );
                EditorGUI.indentLevel = 0;
            }
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();
        }
        /* ---------------------------------------- > END ASSIGNED VARIABLES < ---------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region SIZE AND PLACEMENT
        /* ---------------------------------------- > SIZE AND PLACEMENT < ---------------------------------------- */
        EditorGUILayout.BeginVertical( "Toolbar" );
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField( "Size and Placement", EditorStyles.boldLabel );
        string sap_option = "Show";
        if( EditorPrefs.GetBool( "UUI_SizeAndPlacement" ) == true )
            sap_option = "Hide";
        if( GUILayout.Button( sap_option, EditorStyles.miniButton, GUILayout.Width( 50 ), GUILayout.Height( 14f ) ) )//
        {
            if( EditorPrefs.GetBool( "UUI_SizeAndPlacement" ) == true )
                EditorPrefs.SetBool( "UUI_SizeAndPlacement", false );
            else
                EditorPrefs.SetBool( "UUI_SizeAndPlacement", true );
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        if( EditorPrefs.GetBool( "UUI_SizeAndPlacement" ) == true )
        {
            EditorGUILayout.Space();
            // Arrange our button variables to be shown the way we want
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( anchor, new GUIContent( "Anchor", "The side of the screen that the\njoystick will be anchored to" ) );
            EditorGUILayout.PropertyField( joystickTouchSize, new GUIContent( "Touch Size", "The size of the area in which\nthe touch can be initiated" ) );
            EditorGUILayout.Slider( joystickSize, 1.0f, 4.0f, new GUIContent( "Joystick Size", "The overall size of the joystick" ) );
            EditorGUILayout.Slider( radiusModifier, 2.0f, 7.0f, new GUIContent( "Radius", "Determines how far the joystick can\nmove visually from the center" ) );
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();

            EditorGUI.BeginChangeCheck();
            uj.touchBasedPositioning = EditorGUILayout.ToggleLeft( new GUIContent( "Touch Based Positioning", "Moves the joystick to the position\nof the initial touch" ), uj.touchBasedPositioning );
            if( EditorGUI.EndChangeCheck() )
                EditorUtility.SetDirty( target );

            if( uj.touchBasedPositioning == true )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                uj.overrideTouchSize = EditorGUILayout.Toggle( new GUIContent( "Override Size", "Allows a large section of the screen\nto be used for input" ), uj.overrideTouchSize, EditorStyles.radioButton );
                if( EditorGUI.EndChangeCheck() )
                    EditorUtility.SetDirty( target );

                if( uj.overrideTouchSize == true )
                {
                    EditorGUI.indentLevel = 2;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.Slider( tbp_X, 0.0f, 100.0f, new GUIContent( "Width", "The width of the Joystick Touch Area" ) );
                    EditorGUILayout.Slider( tbp_Y, 0.0f, 100.0f, new GUIContent( "Height", "The height of the Joystick Touch Area" ) );
                    if( EditorGUI.EndChangeCheck() )
                        serializedObject.ApplyModifiedProperties();
                }
                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            else
            {
                if( uj.overrideTouchSize == true )
                    uj.overrideTouchSize = false;
            }

            EditorGUILayout.BeginVertical( "Box" );
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField( new GUIContent( "Joystick Positioning", "Customize the position of the joystick" ) );
            string cs_option = "+";
            if( EditorPrefs.GetBool( "UUI_CustomSpacing" ) == true )
                cs_option = "-";
            if( GUILayout.Button( cs_option, GUILayout.Width( 35 ), GUILayout.Height( 14f ) ) )
            {
                if( EditorPrefs.GetBool( "UUI_CustomSpacing" ) == true )
                    EditorPrefs.SetBool( "UUI_CustomSpacing", false );
                else
                    EditorPrefs.SetBool( "UUI_CustomSpacing", true );
            }
            GUILayout.EndHorizontal();
            if( EditorPrefs.GetBool( "UUI_CustomSpacing" ) == true )
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider( cs_X, 0.0f, 50.0f, new GUIContent( "X Position:" ) );
                EditorGUILayout.Slider( cs_Y, 0.0f, 100.0f, new GUIContent( "Y Position:" ) );
                if( EditorGUI.EndChangeCheck() )
                    serializedObject.ApplyModifiedProperties();

                EditorGUILayout.Space();
                EditorGUI.indentLevel = 0;
            }
            EditorGUILayout.EndVertical();
        }
        /* ---------------------------------------- > END SIZE AND PLACEMENT < ---------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region STYLE AND OPTIONS
        /* ---------------------------------------- > STYLE AND OPTIONS < ---------------------------------------- */
        EditorGUILayout.BeginVertical( "Toolbar" );
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField( "Style and Options", EditorStyles.boldLabel );
        string sao_option = "Show";
        if( EditorPrefs.GetBool( "UUI_StyleAndOptions" ) == true )
            sao_option = "Hide";
        if( GUILayout.Button( sao_option, EditorStyles.miniButton, GUILayout.Width( 50 ), GUILayout.Height( 14f ) ) )//
        {
            if( EditorPrefs.GetBool( "UUI_StyleAndOptions" ) == true )
                EditorPrefs.SetBool( "UUI_StyleAndOptions", false );
            else
                EditorPrefs.SetBool( "UUI_StyleAndOptions", true );
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        if( EditorPrefs.GetBool( "UUI_StyleAndOptions" ) == true )
        {
            EditorGUILayout.Space();
            // TouchPad
            EditorGUI.BeginChangeCheck();
            uj.touchPad = EditorGUILayout.ToggleLeft( new GUIContent( "Touch Pad", "Disables the visuals of the joystick" ), uj.touchPad );
            if( EditorGUI.EndChangeCheck() )
                EditorUtility.SetDirty( target );

            if( uj.touchPad == true )
            {
                if( uj.showHighlight == true )
                    uj.showHighlight = false;
                if( uj.showTension == true )
                    uj.showTension = false;
                if( uj.joystickBase.enabled == true )
                    uj.joystickBase.enabled = false;
                if( uj.joystick.GetComponent<Image>().enabled == true )
                    uj.joystick.GetComponent<Image>().enabled = false;

                // Set our HL and Tension
                uj.SetHighlight();
                uj.SetTensionAccent();
            }
            else
            {
                if( uj.joystickBase.enabled == false )
                    uj.joystickBase.enabled = true;
                if( uj.joystick.GetComponent<Image>().enabled == false )
                    uj.joystick.GetComponent<Image>().enabled = true;
            }

            // Throwable Joystick
            EditorGUI.BeginChangeCheck();
            uj.throwable = EditorGUILayout.ToggleLeft( new GUIContent( "Throwable", "Smoothly transitions the joystick back to\ncenter when the input is released" ), uj.throwable );
            if( EditorGUI.EndChangeCheck() )
                EditorUtility.SetDirty( target );

            if( uj.throwable == true )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider( throwDuration, 0.05f, 1.0f, new GUIContent( "Throw Duration", "Time in seconds to return to center" ) );
                if( EditorGUI.EndChangeCheck() )
                    serializedObject.ApplyModifiedProperties();

                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if( uj.touchPad == false )
            {
                // Show Highlight
                EditorGUI.BeginChangeCheck();
                uj.showHighlight = EditorGUILayout.ToggleLeft( new GUIContent( "Show Highlight", "Shows custom highlight color on the\njoystick" ), uj.showHighlight );
                if( EditorGUI.EndChangeCheck() )
                {
                    EditorUtility.SetDirty( target );
                    uj.SetHighlight();
                }

                if( uj.showHighlight == true )
                {
                    // Highlight Options
                    EditorGUI.indentLevel = 1;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField( highlightColor );
                    if( EditorGUI.EndChangeCheck() )
                        serializedObject.ApplyModifiedProperties();

                    EditorGUI.indentLevel = 0;

                    uj.SetHighlight();

                    // If any of the variables are unassigned, we want to tell them
                    if( uj.highlightBase == null && uj.highlightJoystick == null )
                        EditorGUILayout.HelpBox( "Base and Joystick Highlight will not be displayed.", MessageType.Warning );
                    else if( uj.highlightBase == null && uj.highlightJoystick != null )
                        EditorGUILayout.HelpBox( "Base Highlight will not be displayed", MessageType.Warning );
                    else if( uj.highlightBase != null && uj.highlightJoystick == null )
                        EditorGUILayout.HelpBox( "Joystick Highlight will not be displayed", MessageType.Warning );

                    EditorGUILayout.Space();
                }

                // Show Tension
                EditorGUI.BeginChangeCheck();
                uj.showTension = EditorGUILayout.ToggleLeft( new GUIContent( "Show Tension", "Displays the distance and direction of the\njoystick visually with custom colors" ), uj.showTension );
                if( EditorGUI.EndChangeCheck() )
                {
                    EditorUtility.SetDirty( target );
                    uj.SetTensionAccent();
                }

                if( uj.showTension == true )
                {
                    // Tension Options and Variables
                    EditorGUI.indentLevel = 1;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField( tensionColorNone, new GUIContent( "Tension None", "The color displayed when the joystick\nis not being touched" ) );
                    EditorGUILayout.PropertyField( tensionColorFull, new GUIContent( "Tension Full", "The color displayed when the joystick\nis at the furthest distance" ) );
                    if( EditorGUI.EndChangeCheck() )
                        serializedObject.ApplyModifiedProperties();

                    EditorGUI.indentLevel = 0;
                    EditorGUILayout.Space();

                    uj.SetTensionAccent();
                }
            }

            // This if for using constraints and boundries
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( axis, new GUIContent( "Axis", "Contrains the joystick to a certain axis" ) );
            EditorGUILayout.PropertyField( boundary, new GUIContent( "Boundry", "Determines how the joystick's position is clamped" ) );
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();
        }
        /* ---------------------------------------- > END STYLE AND OPTIONS < ---------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region TOUCH ACTIONS
        /* ---------------------------------------- > TOUCH ACTIONS < ---------------------------------------- */
        EditorGUILayout.BeginVertical( "Toolbar" );
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField( "Touch Actions", EditorStyles.boldLabel );
        string ta_option = "Show";
        if( EditorPrefs.GetBool( "UUI_TouchActions" ) == true )
            ta_option = "Hide";
        if( GUILayout.Button( ta_option, EditorStyles.miniButton, GUILayout.Width( 50 ), GUILayout.Height( 14f ) ) )//
        {
            if( EditorPrefs.GetBool( "UUI_TouchActions" ) == true )
                EditorPrefs.SetBool( "UUI_TouchActions", false );
            else
                EditorPrefs.SetBool( "UUI_TouchActions", true );
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        if( EditorPrefs.GetBool( "UUI_TouchActions" ) == true )
        {
            EditorGUILayout.Space();
            // This is for calculating our taps within a time window
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( tapCountOption, new GUIContent( "Tap Count", "Allows the joystick to calculate double taps and a touch and release within a certain time window" ) );
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();

            if( uj.tapCountOption != UltimateJoystick.TapCountOption.NoCount )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField( tapCountEvent );
                EditorGUILayout.Slider( tapCountDuration, 0.0f, 1.0f, new GUIContent( "Tap Time Window", "Time in seconds that the joystick can recieve taps" ) );
                if( uj.tapCountOption == UltimateJoystick.TapCountOption.Accumulate )
                    EditorGUILayout.IntSlider( targetTapCount, 1, 5, new GUIContent( "Target Tap Count", "How many taps to activate the Tap Count Event?" ) );
                if( EditorGUI.EndChangeCheck() )
                    serializedObject.ApplyModifiedProperties();

                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }

            // This is for implementing our touch actions with animations
            EditorGUI.BeginChangeCheck();
            uj.useAnimation = EditorGUILayout.ToggleLeft( new GUIContent( "Use Animation", "Play animation in reaction to input" ), uj.useAnimation );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                uj.SetAnimation();
            }
            if( uj.useAnimation == true )
            {
                EditorGUI.indentLevel = 1;

                if( uj.joystickAnimator == null )
                    EditorGUILayout.HelpBox( "Joystick Animator needs to be assigned.", MessageType.Error );

                EditorGUI.indentLevel = 0;
            }
            // This is for implementing color fading with touch
            EditorGUI.BeginChangeCheck();
            uj.useFade = EditorGUILayout.ToggleLeft( new GUIContent( "Use Fade", "Fade joystick visuals when touched,\nand released?" ), uj.useFade );
            if( EditorGUI.EndChangeCheck() )
            {
                EditorUtility.SetDirty( target );
                if( uj.useFade == true )
                    uj.HandleFade( "Untouched" );
                else
                    uj.HandleFade( "Reset" );
            }
            if( uj.useFade == true )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider( fadeUntouched, 0.0f, 1.0f, new GUIContent( "Fade Untouched", "The alpha of the joystick when it is NOT receiving input" ) );
                EditorGUILayout.Slider( fadeTouched, 0.0f, 1.0f, new GUIContent( "Fade Touched", "The alpha of the joystick when receiving input" ) );
                if( EditorGUI.EndChangeCheck() )
                    serializedObject.ApplyModifiedProperties();

                uj.HandleFade( "Untouched" );

                if( uj.showTension == true )
                    EditorGUILayout.HelpBox( "The alpha of Tension Color will not fade. If you want to change the alpha of the Tension Color, modify it with the Tension Color property directly.", MessageType.Warning );
                EditorGUI.indentLevel = 0;
            }
        }
        /* ---------------------------------------- > END TOUCH ACTIONS < ---------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region RESETS
        /* ---------------------------------------- > RESETS < ---------------------------------------- */
        EditorGUILayout.BeginVertical( "Toolbar" );
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField( "Restore To Default", EditorStyles.boldLabel );
        string rtd_option = "Show";
        if( EditorPrefs.GetBool( "UUI_RestoreToDefault" ) == true )
            rtd_option = "Hide";
        if( GUILayout.Button( rtd_option, EditorStyles.miniButton, GUILayout.Width( 50 ), GUILayout.Height( 14f ) ) )
        {
            if( EditorPrefs.GetBool( "UUI_RestoreToDefault" ) == true )
                EditorPrefs.SetBool( "UUI_RestoreToDefault", false );
            else
                EditorPrefs.SetBool( "UUI_RestoreToDefault", true );
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        if( EditorPrefs.GetBool( "UUI_RestoreToDefault" ) == true )
        {
            // In this section, we just are setting up hard coded values to be able to reset our options to
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if( GUILayout.Button( "Size and Placement", EditorStyles.miniButton, GUILayout.Width( 120 ), GUILayout.Height( 20 ) ) )
                if( EditorUtility.DisplayDialog( "Warning!", "Are you sure you reset the Size and Placement options back to default?", "Yes", "No" ) )
                    ResetSizeAndPlacement( uj );
            if( GUILayout.Button( "Style and Options", EditorStyles.miniButton, GUILayout.Width( 120 ), GUILayout.Height( 20 ) ) )
                if( EditorUtility.DisplayDialog( "Warning!", "Are you sure you reset the Style and Options options back to default?", "Yes", "No" ) )
                    ResetStyleAndOptions( uj );
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if( GUILayout.Button( "Touch Actions", EditorStyles.miniButton, GUILayout.Width( 120 ), GUILayout.Height( 20 ) ) )
                if( EditorUtility.DisplayDialog( "Warning!", "Are you sure you reset the Touch Actions options back to default?", "Yes", "No" ) )
                    ResetTouchActions( uj );
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        /* ---------------------------------------- > END RESETS < ---------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        // This is for showing helpful tips to help them avoid errors
        if( uj.joystick == null )
            EditorGUILayout.HelpBox( "Joystick needs to be assigned in 'Assigned Variables'!", MessageType.Error );
        if( uj.joystickSizeFolder == null )
            EditorGUILayout.HelpBox( "Joystick Size Folder needs to be assigned in 'Assigned Variables'!", MessageType.Error );
    }
Example #47
0
 // Use this for initialization
 void Start()
 {
     scaler = GetComponent<CanvasScaler>();
 }
Example #48
0
 void Start()
 {
     mText = GetComponentInChildren<Text>();
     mCornerImage = transform.Find("Corner").GetComponent<RectTransform>();
     mGUIMode = transform.parent.GetComponent<Canvas>().renderMode;
     mScaler = transform.parent.GetComponent<CanvasScaler>();
     HideTooltip();
 }
 private void Start()
 {
     Verify();
     _canvasScaler = GetComponentInParent<CanvasScaler>();
 }
 void Start()
 {
     canvasScaler = canvas.GetComponent<CanvasScaler>();
     canvasScaler.scaleFactor = 1/(1024f/screenWidth);
 }
Example #51
0
 // Use this for initialization
 void Start()
 {
     csScript = GetComponent<CanvasScaler>();
 }