public GetSides ( Transform relativeTo ) : Vector3[] | ||
relativeTo | Transform | |
return | Vector3[] |
public void SetHorizontal(Transform parent, float localPos) { if ((bool)rect) { Vector3[] sides = rect.GetSides(parent); float num = Mathf.Lerp(sides[0].x, sides[2].x, relative); absolute = Mathf.FloorToInt(localPos - num + 0.5f); return; } Vector3 position = target.position; if (parent != null) { position = parent.InverseTransformPoint(position); } absolute = Mathf.FloorToInt(localPos - position.x + 0.5f); }
/// <summary> /// Set the anchor's absolute coordinate relative to the specified parent, keeping the relative setting intact. /// </summary> public void SetHorizontal(Transform parent, float localPos) { if (rect) { Vector3[] sides = rect.GetSides(parent); float targetPos = Mathf.Lerp(sides[0].x, sides[2].x, relative); absolute = Mathf.FloorToInt(localPos - targetPos + 0.5f); } else { Vector3 targetPos = target.position; if (parent != null) { targetPos = parent.InverseTransformPoint(targetPos); } absolute = Mathf.FloorToInt(localPos - targetPos.x + 0.5f); } }
static int GetSides(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); UIRect obj = (UIRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIRect"); Transform arg0 = (Transform)LuaScriptMgr.GetUnityObject(L, 2, typeof(Transform)); Vector3[] o = obj.GetSides(arg0); LuaScriptMgr.PushArray(L, o); return(1); }
private static int GetSides(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); UIRect uIRect = (UIRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIRect"); Transform relativeTo = (Transform)LuaScriptMgr.GetUnityObject(L, 2, typeof(Transform)); Vector3[] sides = uIRect.GetSides(relativeTo); LuaScriptMgr.PushArray(L, sides); return(1); }
static int GetSides(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); UIRect obj = LuaScriptMgr.GetNetObject <UIRect>(L, 1); Transform arg0 = LuaScriptMgr.GetNetObject <Transform>(L, 2); Vector3[] o = obj.GetSides(arg0); LuaScriptMgr.PushArray(L, o); return(1); }
public void SetHorizontal(Transform parent, float localPos) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit(rect)) { Vector3[] sides = rect.GetSides(parent); float num = Mathf.Lerp(sides[0].x, sides[2].x, relative); absolute = Mathf.FloorToInt(localPos - num + 0.5f); } else { Vector3 val = target.get_position(); if (parent != null) { val = parent.InverseTransformPoint(val); } absolute = Mathf.FloorToInt(localPos - val.x + 0.5f); } }
static public int GetSides(IntPtr l) { try { UIRect self = (UIRect)checkSelf(l); UnityEngine.Transform a1; checkType(l, 2, out a1); var ret = self.GetSides(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static int GetSides(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UIRect obj = (UIRect)ToLua.CheckObject <UIRect>(L, 1); UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2); UnityEngine.Vector3[] o = obj.GetSides(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private static int GetSides(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 2); UIRect uIRect = (UIRect)ToLua.CheckObject(L, 1, typeof(UIRect)); Transform relativeTo = (Transform)ToLua.CheckUnityObject(L, 2, typeof(Transform)); Vector3[] sides = uIRect.GetSides(relativeTo); ToLua.Push(L, sides); result = 1; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
public static int GetSides(IntPtr l) { int result; try { UIRect uIRect = (UIRect)LuaObject.checkSelf(l); Transform relativeTo; LuaObject.checkType <Transform>(l, 2, out relativeTo); Vector3[] sides = uIRect.GetSides(relativeTo); LuaObject.pushValue(l, true); LuaObject.pushValue(l, sides); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
/// <summary> /// Helper function that draws the suffix after the relative fields. /// </summary> void DrawAnchor(int index, bool targetSelection) { if (targetSelection) { GUILayout.Space(3f); } NGUIEditorTools.SetLabelWidth(16f); GUILayout.BeginHorizontal(); GUILayout.Label(PrefixName[index], GUILayout.Width(56f)); UIRect myRect = serializedObject.targetObject as UIRect; string name = FieldName[index]; SerializedProperty tar = serializedObject.FindProperty(name + ".target"); SerializedProperty rel = serializedObject.FindProperty(name + ".relative"); SerializedProperty abs = serializedObject.FindProperty(name + ".absolute"); if (targetSelection) { Object before = tar.objectReferenceValue; NGUIEditorTools.DrawProperty("", tar, false); Object after = tar.objectReferenceValue; if (after != null || tar.hasMultipleDifferentValues) { if (before != after && after != null) { UpdateAnchor(index); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(64f); } UIRect targetRect = GetRect(tar); Camera targetCam = GetCamera(tar); float relative = rel.floatValue; bool isCommon = (targetRect == null && targetCam == null) || IsCommon(relative); int previousOrigin = 1; if (targetRect != null || targetCam != null) { if (mCustom[index] || !isCommon) { previousOrigin = 3; } else if (relative == 0f) { previousOrigin = 0; } else if (relative == 1f) { previousOrigin = 2; } } // Draw the origin selection list EditorGUI.BeginDisabledGroup(targetRect == null && targetCam == null); int newOrigin = IsHorizontal[index] ? EditorGUILayout.Popup(previousOrigin, HorizontalList, GUILayout.MinWidth(110f)) : EditorGUILayout.Popup(previousOrigin, VerticalList, GUILayout.MinWidth(110f)); EditorGUI.EndDisabledGroup(); // "Set to Current" choice if (newOrigin == 4) { newOrigin = 3; Vector3[] sides = targetRect.GetSides(myRect.cachedTransform); float f0, f1; if (IsHorizontal[index]) { f0 = sides[0].x; f1 = sides[2].x; } else { f0 = sides[3].y; f1 = sides[1].y; } // Final position after both relative and absolute values are taken into consideration float final = Mathf.Floor(0.5f + Mathf.Lerp(0f, f1 - f0, rel.floatValue) + abs.intValue); rel.floatValue = final / (f1 - f0); abs.intValue = 0; serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } mCustom[index] = (newOrigin == 3); // If the origin changes if (newOrigin != 3 && previousOrigin != newOrigin) { // Desired relative value if (newOrigin == 0) { relative = 0f; } else if (newOrigin == 2) { relative = 1f; } else { relative = 0.5f; } Vector3[] sides = (targetRect != null) ? targetRect.GetSides(myRect.cachedTransform) : targetCam.GetSides(myRect.cachedTransform); // Calculate the current position based from the bottom-left float f0, f1; if (IsHorizontal[index]) { f0 = sides[0].x; f1 = sides[2].x; } else { f0 = sides[3].y; f1 = sides[1].y; } // Final position after both relative and absolute values are taken into consideration float final = Mathf.Floor(0.5f + Mathf.Lerp(f0, f1, rel.floatValue) + abs.intValue); rel.floatValue = relative; abs.intValue = Mathf.FloorToInt(final + 0.5f - Mathf.Lerp(f0, f1, relative)); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } if (!mCustom[index]) { // Draw the absolute value NGUIEditorTools.SetLabelWidth(16f); NGUIEditorTools.DrawProperty("+", abs, true, GUILayout.MinWidth(10f)); } else { // Draw the relative value NGUIEditorTools.SetLabelWidth(16f); NGUIEditorTools.DrawProperty(" ", rel, true, GUILayout.MinWidth(10f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(64f); relative = rel.floatValue; bool isOutside01 = relative <0f || relative> 1f; // Horizontal slider for relative values, for convenience EditorGUI.BeginDisabledGroup(isOutside01); { float val = GUILayout.HorizontalSlider(relative, 0f, 1f, GUILayout.MinWidth(110f)); if (!isOutside01 && val != relative) { Vector3[] sides = (targetRect != null) ? targetRect.GetSides(myRect.cachedTransform) : targetCam.GetSides(myRect.cachedTransform); // Calculate the current position based from the bottom-left float f0, f1; if (IsHorizontal[index]) { f0 = sides[0].x; f1 = sides[2].x; } else { f0 = sides[3].y; f1 = sides[1].y; } float size = (f1 - f0); int intVal = Mathf.FloorToInt(val * size + 0.5f); //intVal = ((intVal >> 1) << 1); rel.floatValue = (size > 0f) ? intVal / size : 0.5f; } } EditorGUI.EndDisabledGroup(); // Draw the absolute value NGUIEditorTools.DrawProperty("+", abs, true, GUILayout.MinWidth(10f)); } GUILayout.EndHorizontal(); NGUIEditorTools.SetLabelWidth(62f); }