Example #1
0
    //Aligning all elements and calculating hover
    public void  Update()
    {
        //if (updateTime > 0.1f && updateTimeLeft > 0) { updateTimeLeft-=Time.deltaTime; return; }
        //updateTimeLeft = updateTime;

        //if (!element)
        element = GetComponent <InstantGuiElement>();
        pointed = null;

        //getting game view size
                #if UNITY_EDITOR
        /*
         * if (!gameView)
         * {
         *      System.Type type = System.Type.GetType("UnityEditor.GameView,UnityEditor");
         *      System.Reflection.MethodInfo GetMainGameView = type.GetMethod("GetMainGameView",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
         *      gameView = (UnityEditor.EditorWindow)GetMainGameView.Invoke(null,null);
         * }
         * width = (int)gameView.position.width;
         * height = (int)gameView.position.height-16;
         */

        //It is not possible to use Screen.height from an OnInspectorGUI (returns inspector height)
        string[] res = UnityEditor.UnityStats.screenRes.Split('x');
        width  = int.Parse(res[0]);
        height = int.Parse(res[1]);
                #else
        width  = Screen.width;
        height = Screen.height;
                #endif

        UnityEngine.Profiling.Profiler.BeginSample("CheckChildren");
        element.CheckChildren();
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Align");
        element.Align();
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Prevent Zero Size");
        //element.PreventZeroSize();
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Point");
        element.Point();
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Action");
        element.Action();
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Style");
        element.ApplyStyle();
        UnityEngine.Profiling.Profiler.EndSample();

        oldScreenWidth  = UnityEngine.Screen.width;
        oldScreenHeight = UnityEngine.Screen.height;
    }
	public void  InvertAlign ( InstantGuiElement element  )
	{
		int tmp = element.relative.top;
		element.relative.top = 100-element.relative.bottom;
		element.relative.bottom = 100-tmp;
		
		tmp = element.offset.top;
		element.offset.top = -element.offset.bottom;
		element.offset.bottom = -tmp;
		
		invertedAlign = !invertedAlign;
		element.Align();
	}
Example #3
0
    public void  InvertAlign(InstantGuiElement element)
    {
        int tmp = element.relative.top;

        element.relative.top    = 100 - element.relative.bottom;
        element.relative.bottom = 100 - tmp;

        tmp = element.offset.top;
        element.offset.top    = -element.offset.bottom;
        element.offset.bottom = -tmp;

        invertedAlign = !invertedAlign;
        element.Align();
    }
Example #4
0
	//Aligning all elements and calculating hover
	public void  Update ()
	{
		//if (updateTime > 0.1f && updateTimeLeft > 0) { updateTimeLeft-=Time.deltaTime; return; }
		//updateTimeLeft = updateTime;
		
		//if (!element) 
		element = GetComponent<InstantGuiElement>();
		pointed = null;
		
		//getting game view size
		#if UNITY_EDITOR
		/*
		if (!gameView)
		{
			System.Type type = System.Type.GetType("UnityEditor.GameView,UnityEditor");
			System.Reflection.MethodInfo GetMainGameView = type.GetMethod("GetMainGameView",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
			gameView = (UnityEditor.EditorWindow)GetMainGameView.Invoke(null,null);
		}
		width = (int)gameView.position.width;
		height = (int)gameView.position.height-16;
		*/
		
		//It is not possible to use Screen.height from an OnInspectorGUI (returns inspector height)
		string[] res = UnityEditor.UnityStats.screenRes.Split('x');
		width = int.Parse(res[0]);
		height = int.Parse(res[1]);
		
		#else
		width = Screen.width;
		height = Screen.height;
		#endif

		Profiler.BeginSample ("CheckChildren");	
		element.CheckChildren(); 
		Profiler.EndSample ();
		
		Profiler.BeginSample ("Align");	
		element.Align();
		Profiler.EndSample ();
		
		Profiler.BeginSample ("Prevent Zero Size");	
		//element.PreventZeroSize();
		Profiler.EndSample ();
		
		Profiler.BeginSample ("Point");	
		element.Point();
		Profiler.EndSample ();
		
		Profiler.BeginSample ("Action");	
		element.Action();
		Profiler.EndSample ();
		
		Profiler.BeginSample ("Style");	
		element.ApplyStyle();
		Profiler.EndSample ();
		
		oldScreenWidth = Screen.width;
		oldScreenHeight = Screen.height;
	}