UnityEngine.GUIUtility.ScaleAroundPivot(UnityEngine.Vector2, UnityEngine.Vector2)

Here are the examples of the csharp api UnityEngine.GUIUtility.ScaleAroundPivot(UnityEngine.Vector2, UnityEngine.Vector2) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

9 Examples 7

19 View Source File : UnityEngine_GUIUtility_Wrap.cs
License : MIT License
Project Creator : focus-creative-games

[Puerts.MonoPInvokeCallback(typeof(Puerts.V8FunctionCallback))]
        private static void F_ScaleAroundPivot(IntPtr isolate, IntPtr info, IntPtr self, int paramLen, long data)
        {
            try
            {
                
                
                
                {
                    
                    var argHelper0 = new Puerts.ArgumentHelper((int)data, isolate, info, 0);
                    var argHelper1 = new Puerts.ArgumentHelper((int)data, isolate, info, 1);
                    
                    
                    
                    {
                        
                        var Arg0 = argHelper0.Get<UnityEngine.Vector2>(false);
                        var Arg1 = argHelper1.Get<UnityEngine.Vector2>(false);
                        UnityEngine.GUIUtility.ScaleAroundPivot(Arg0,Arg1);
                        
                        
                        
                        
                    }
                }
                
                
            }
            catch (Exception e)
            {
                Puerts.PuertsDLL.ThrowException(isolate, "c# exception:" + e.Message + ",stack:" + e.StackTrace);
            }
        }

19 View Source File : NodeEditorGUI.cs
License : MIT License
Project Creator : Interactml

public static void BeginZoomed(Rect rect, float zoom, float topPadding) {
            GUI.EndClip();

            GUIUtility.ScaleAroundPivot(Vector2.one / zoom, rect.size * 0.5f);
            Vector4 padding = new Vector4(0, topPadding, 0, 0);
            padding *= zoom;
            GUI.BeginClip(new Rect(-((rect.width * zoom) - rect.width) * 0.5f, -(((rect.height * zoom) - rect.height) * 0.5f) + (topPadding * zoom),
                rect.width * zoom,
                rect.height * zoom));
        }

19 View Source File : NodeEditorGUI.cs
License : MIT License
Project Creator : Interactml

public static void EndZoomed(Rect rect, float zoom, float topPadding) {
            GUIUtility.ScaleAroundPivot(Vector2.one * zoom, rect.size * 0.5f);
            Vector3 offset = new Vector3(
                (((rect.width * zoom) - rect.width) * 0.5f),
                (((rect.height * zoom) - rect.height) * 0.5f) + (-topPadding * zoom) + topPadding,
                0);
            GUI.matrix = Matrix4x4.TRS(offset, Quaternion.idenreplacedy, Vector3.one);
        }

19 View Source File : EditorZoomArea.cs
License : MIT License
Project Creator : PacktPublishing

public static Vector2 BeginScale(ref Rect rect, Vector2 zoomPivot, float zoom, bool adjustGUILayout)
		{
			Rect screenRect;
			if (compabilityMode)
			{ // In compability mode, we will replacedume only one top group and do everything manually, not using reflected calls (-> practically blind)
				GUI.EndGroup();
				screenRect = rect;
#if UNITY_EDITOR
				if (!Application.isPlaying)
					screenRect.y += 23;
#endif
			}
			else
			{ // If it's supported, we take the completely generic way using reflected calls
				GUIScaleUtility.BeginNoClip();
				screenRect = GUIScaleUtility.GUIToScaledSpace(rect);
			}

			rect = Scale(screenRect, screenRect.position + zoomPivot, new Vector2(zoom, zoom));

			// Now continue drawing using the new clipping group
			GUI.BeginGroup(rect);
			rect.position = Vector2.zero; // Adjust because we entered the new group

			// Because I currently found no way to actually scale to a custom pivot rather than (0, 0),
			// we'll make use of a cheat and just offset it accordingly to let it appear as if it would scroll to the center
			// Note, due to that, controls not adjusted are still scaled to (0, 0)
			Vector2 zoomPosAdjust = rect.center - screenRect.size / 2 + zoomPivot;

			// For GUILayout, we can make this adjustment here if desired
			adjustedGUILayout.Add(adjustGUILayout);
			if (adjustGUILayout)
			{
				GUILayout.BeginHorizontal();
				GUILayout.Space(rect.center.x - screenRect.size.x + zoomPivot.x);
				GUILayout.BeginVertical();
				GUILayout.Space(rect.center.y - screenRect.size.y + zoomPivot.y);
			}

			// Take a matrix backup to restore back later on
			GUIMatrices.Add(GUI.matrix);

			// Scale GUI.matrix. After that we have the correct clipping group again.
			GUIUtility.ScaleAroundPivot(new Vector2(1 / zoom, 1 / zoom), zoomPosAdjust);

			return zoomPosAdjust;
		}

19 View Source File : GuiDraw.cs
License : Apache License 2.0
Project Creator : sintefneodroid

public static void DrawLine(Vector2 p_point_a, Vector2 p_point_b, float p_width) {
      var save_matrix = GUI.matrix;
      var save_color = GUI.color;

      var delta = p_point_b - p_point_a;
      GUIUtility.ScaleAroundPivot(new Vector2(delta.magnitude, p_width), Vector2.zero);
      GUIUtility.RotateAroundPivot(Vector2.Angle(delta, Vector2.right) * Mathf.Sign(delta.y), Vector2.zero);
      GUI.matrix = Matrix4x4.TRS(p_point_a, Quaternion.idenreplacedy, Vector3.one) * GUI.matrix;

      GUI.DrawTexture(new Rect(Vector2.zero, Vector2.one), _s_line_tex);

      GUI.matrix = save_matrix;
      GUI.color = save_color;
    }

19 View Source File : GUIScaleUtility.cs
License : MIT License
Project Creator : virror

public static Vector2 BeginScale (ref Rect rect, Vector2 zoomPivot, float zoom, bool IsEditorWindow, bool adjustGUILayout) 
		{
			isEditorWindow = IsEditorWindow;

			Rect screenRect;
			if (compabilityMode) 
			{ // In compability mode, we will replacedume only one top group and do everything manually, not using reflected calls (-> practically blind)
				GUI.EndGroup ();
				screenRect = rect;
				#if UNITY_EDITOR
				if (isEditorWindow)
					screenRect.y += 23;
				#endif
			}
			else
			{ // If it's supported, we take the completely generic way using reflected calls
				GUIScaleUtility.BeginNoClip ();
				screenRect = GUIScaleUtility.GUIToScaledSpace (rect);
			}

			rect = Scale (screenRect, screenRect.position + zoomPivot, new Vector2 (zoom, zoom));

			// Now continue drawing using the new clipping group
			GUI.BeginGroup (rect);
			rect.position = Vector2.zero; // Adjust because we entered the new group

			// Because I currently found no way to actually scale to a custom pivot rather than (0, 0),
			// we'll make use of a cheat and just offset it accordingly to let it appear as if it would scroll to the center
			// Note, due to that, controls not adjusted are still scaled to (0, 0)
			Vector2 zoomPosAdjust = rect.center - screenRect.size/2 + zoomPivot;

			// For GUILayout, we can make this adjustment here if desired
			adjustedGUILayout.Add (adjustGUILayout);
			if (adjustGUILayout)
			{
				GUILayout.BeginHorizontal ();
				GUILayout.Space (rect.center.x - screenRect.size.x + zoomPivot.x);
				GUILayout.BeginVertical ();
				GUILayout.Space (rect.center.y - screenRect.size.y + zoomPivot.y);
			}

			// Take a matrix backup to restore back later on
			GUIMatrices.Add (GUI.matrix);

			// Scale GUI.matrix. After that we have the correct clipping group again.
			GUIUtility.ScaleAroundPivot (new Vector2 (1/zoom, 1/zoom), zoomPosAdjust);

			return zoomPosAdjust;
		}

19 View Source File : GUIScaleUtility.cs
License : MIT License
Project Creator : wqaetly

public static Vector2 BeginScale (ref Rect rect, Vector2 zoomPivot, float zoom, bool IsEditorWindow, bool adjustGUILayout) 
		{
			isEditorWindow = IsEditorWindow;

			Rect screenRect;
			if (compabilityMode) 
			{ // In compability mode, we will replacedume only one top group and do everything manually, not using reflected calls (-> practically blind)
				GUI.EndGroup ();
				screenRect = rect;
				#if UNITY_EDITOR
				if (isEditorWindow)
					screenRect.y += 23;
				#endif
			}
			else
			{ // If it's supported, we take the completely generic way using reflected calls
				GUIScaleUtility.BeginNoClip ();
				screenRect = GUIScaleUtility.GUIToScaledSpace (rect);
			}

			rect = Scale (screenRect, screenRect.position + zoomPivot, new Vector2 (zoom, zoom));

			// Now continue drawing using the new clipping group
			GUI.BeginGroup (rect);
			rect.position = Vector2.zero; // Adjust because we entered the new group

			// Because I currently found no way to actually scale to a custom pivot rather than (0, 0),
			// we'll make use of a cheat and just offset it accordingly to let it appear as if it would scroll to the center
			// Note, due to that, controls not adjusted are still scaled to (0, 0)
			Vector2 zoomPosAdjust = rect.center - screenRect.size/2 + zoomPivot;

			// For GUILayout, we can make this adjustment here if desired
			adjustedGUILayout.Add (adjustGUILayout);
			if (adjustGUILayout)
			{
				GUILayout.BeginHorizontal ();
				GUILayout.Space (rect.center.x - screenRect.size.x + zoomPivot.x);
				GUILayout.BeginVertical ();
				GUILayout.Space (rect.center.y - screenRect.size.y + zoomPivot.y);
			}

			// Take a matrix backup to restore back later on
			GUIMatrices.Add (GUI.matrix);

			// Scale GUI.matrix. After that we have the correct clipping group again.
			GUIUtility.ScaleAroundPivot (new Vector2 (1/zoom, 1/zoom), zoomPosAdjust);

			return zoomPosAdjust;
		}

19 View Source File : MediaPlayer.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
		{
			if (m_Info != null && m_DebugGui)
			{
				GUI.depth = s_GuiDepth;
				GUI.matrix = Matrix4x4.TRS(new Vector3(m_GuiPositionX, 10f, 0f), Quaternion.idenreplacedy, new Vector3(s_GuiScale, s_GuiScale, 1.0f));

				GUILayout.BeginVertical("box", GUILayout.MaxWidth(s_GuiWidth));
				GUILayout.Label(System.IO.Path.GetFileName(m_VideoPath));
				GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + "x" + m_Info.GetVideoHeight() + "@" + m_Info.GetVideoFrameRate().ToString("F2"));
				GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s");
				GUILayout.Label("Rate: " + m_Info.GetVideoDisplayRate().ToString("F2") + "Hz");

				if (TextureProducer != null && TextureProducer.GetTexture() != null)
				{
#if REAL_ANDROID
					// In OES mode we can't display the texture without using a special shader, so just don't display it
					if (!_optionsAndroid.useFastOesPath)
#endif
					{
						// Show texture without and with alpha blending
						GUILayout.BeginHorizontal();
						Rect r1 = GUILayoutUtility.GetRect(32f, 32f);
						GUILayout.Space(8f);
						Rect r2 = GUILayoutUtility.GetRect(32f, 32f);
						Matrix4x4 prevMatrix = GUI.matrix;
						if (TextureProducer.RequiresVerticalFlip())
						{
							GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, r1.y + (r1.height / 2f)));
						}
						GUI.DrawTexture(r1, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, false);
						GUI.DrawTexture(r2, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, true);
						GUI.matrix = prevMatrix;
						GUILayout.FlexibleSpace();
						GUILayout.EndHorizontal();
					}
				}

				if (m_DebugGuiControls)
				{
					GUILayout.BeginHorizontal();
					if (m_Control.IsPaused())
					{
						if (GUILayout.Button("Play", GUILayout.Width(50)))
						{
							m_Control.Play();
						}
					}
					else
					{
						if (GUILayout.Button("Pause", GUILayout.Width(50)))
						{
							m_Control.Pause();
						}
					}

					float duration = m_Info.GetDurationMs();
					float time = m_Control.GetCurrentTimeMs();
					float newTime = GUILayout.HorizontalSlider(time, 0f, duration);
					if (newTime != time)
					{
						m_Control.Seek(newTime);
					}
					GUILayout.EndHorizontal();
				}

#if AVPROVIDEO_DEBUG_DISPLAY_EVENTS
				// Dirty code to hack in an event monitor
				if (Event.current.type == EventType.Repaint)
				{
					this.Events.RemoveListener(OnMediaPlayerEvent);
					this.Events.AddListener(OnMediaPlayerEvent);
					UpdateEventLogs();
				}

				if (_eventLog != null && _eventLog.Count > 0)
				{
					GUILayout.Label("Recent Events: ");
					GUILayout.BeginVertical("box");
					int eventIndex = 0;
					foreach (string eventString in _eventLog)
					{
						GUI.color = Color.white;
						if (eventIndex == 0)
						{
							GUI.color = new Color(1f, 1f, 1f, _eventTimer);
						}
						GUILayout.Label(eventString);
						eventIndex++;
					}
					GUILayout.EndVertical();
					GUI.color = Color.white;
				}
#endif
				GUILayout.EndVertical();
			}
		}

19 View Source File : DisplayIMGUI.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
		{
#if UNITY_EDITOR
			if (!Application.isPlaying && _displayInEditor)
			{
				GUI.depth = _depth;
				GUI.color = _color;
				Rect rect = GetRect();
				Texture2D icon = Resources.Load<Texture2D>("AVProVideoIcon");
				Rect uv = rect;
				uv.x /= Screen.width;
				uv.width /= Screen.width;
				uv.y /= Screen.height;
				uv.height /= Screen.height;
				uv.width *= 16f;
				uv.height *= 16f;
				uv.x += 0.5f;
				uv.y += 0.5f;
				GUI.DrawTextureWithTexCoords(rect, icon, uv);
				return;
			}
#endif

			if (_mediaPlayer == null)
			{
				return;
			}

			bool requiresVerticalFlip = false;
			Texture texture = null;

			if (_displayInEditor)
			{
#if UNITY_EDITOR
				texture = Texture2D.whiteTexture;
#endif
			}

			if (_mediaPlayer.Info != null && !_mediaPlayer.Info.HasVideo())
			{
				texture = null;
			}

			if (_mediaPlayer.TextureProducer != null)
			{
				if (_mediaPlayer.TextureProducer.GetTexture() != null)
				{
					texture = _mediaPlayer.TextureProducer.GetTexture();
					requiresVerticalFlip = _mediaPlayer.TextureProducer.RequiresVerticalFlip();
				}

				if (_mediaPlayer.TextureProducer.GetTextureCount() == 2 && _material != null)
				{
					Texture chroma = _mediaPlayer.TextureProducer.GetTexture(1);
					_material.SetTexture("_ChromaTex", chroma);
					_material.EnableKeyword("USE_YPCBCR");
				}
			}

			if (texture != null)
			{
				if (!_alphaBlend || _color.a > 0f)
				{
					GUI.depth = _depth;
					GUI.color = _color;

					Rect rect = GetRect();

					if (_material != null)
					{
						if (requiresVerticalFlip)
						{
							_material.SetFloat(_propVertScale, -1f);
						}
						else
						{
							_material.SetFloat(_propVertScale, 1f);
						}
						Helper.DrawTexture(rect, texture, _scaleMode, _mediaPlayer.m_AlphaPacking, _material);
					}
					else
					{
						if (requiresVerticalFlip)
						{
							GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0f, rect.y + (rect.height / 2f)));
						}
						GUI.DrawTexture(rect, texture, _scaleMode, _alphaBlend);
					}
				}
			}
		}