/// <inheritdoc /> public override void OnPreSceneQuery() { if (LineBase == null) { return; } // Make sure our array will hold if (Rays == null || Rays.Length != LineCastResolution) { Rays = new RayStep[LineCastResolution]; } // Set up our rays // Turn off gravity so we get accurate rays GravityDistorter.enabled = false; float stepSize = 1f / Rays.Length; Vector3 lastPoint = LineBase.GetUnClampedPoint(0f); for (int i = 0; i < Rays.Length; i++) { Vector3 currentPoint = LineBase.GetUnClampedPoint(stepSize * (i + 1)); Rays[i].UpdateRayStep(ref lastPoint, ref currentPoint); lastPoint = currentPoint; } // Re-enable gravity if we're looking at a hotspot GravityDistorter.enabled = (TeleportSurfaceResult == TeleportSurfaceResult.HotSpot); }
public HaveMousePositionTrackerForLineBase(LineBase lineBase) { Line = lineBase ?? throw new ArgumentNullException(nameof(lineBase)); InitializeLine(); }
protected override void PreUpdateLineRenderers() { using (PreUpdateLineRenderersPerfMarker.Auto()) { base.PreUpdateLineRenderers(); bool isFocusedLock = IsFocusLocked && IsTargetPositionLockedOnFocusLock; inertia.enabled = !isFocusedLock; if (isFocusedLock) { float distance = Result != null ? Result.Details.RayDistance : DefaultPointerExtent; Vector3 startPoint = LineBase.FirstPoint; // Project forward based on pointer direction to get an 'expected' position of the first control point Vector3 expectedPoint = startPoint + Rotation * Vector3.forward * distance; // Lerp between the expected position and the expected point LineBase.SetPoint(1, Vector3.Lerp(startPoint, expectedPoint, startPointLerp)); // Get our next 'expected' position by lerping between the expected point and the end point // The result will be a line that starts moving in the pointer's direction then bends towards the target expectedPoint = Vector3.Lerp(expectedPoint, LineBase.LastPoint, endPointLerp); LineBase.SetPoint(2, Vector3.Lerp(startPoint, expectedPoint, endPointLerp)); } } }
static void Common_CommonTask(LineBase line) { if (line.PropertyRoute != null) { line.FormGroupHtmlProps["data-route"] = line.PropertyRoute.ToString(); } }
/// <inheritdoc /> public override void OnPostSceneQuery() { base.OnPostSceneQuery(); LineBase.enabled = IsInteractionEnabled; BaseCursor?.SetVisibility(IsInteractionEnabled); if (!LineBase.enabled) { return; } // The distance the ray travels through the world before it hits something. Measured in world-units (as opposed to normalized distance). float clearWorldLength; Gradient lineColor = LineColorNoTarget; if (Result?.CurrentPointerTarget != null) { // We hit something clearWorldLength = Result.Details.RayDistance; lineColor = LineColorValid; } else { clearWorldLength = DefaultPointerExtent; lineColor = IsSelectPressed ? LineColorSelected : LineColorNoTarget; } if (IsFocusLocked) { lineColor = LineColorLockFocus; } int maxClampLineSteps = LineCastResolution; foreach (BaseMixedRealityLineRenderer lineRenderer in lineRenderers) { // Renderers are enabled by default if line is enabled maxClampLineSteps = Mathf.Max(maxClampLineSteps, lineRenderer.LineStepCount); lineRenderer.LineColor = lineColor; } // Used to ensure the line doesn't extend beyond the cursor float cursorOffsetWorldLength = (BaseCursor != null) ? BaseCursor.SurfaceCursorDistance : 0; // If focus is locked, we're sticking to the target // So don't clamp the world length if (IsFocusLocked && IsTargetPositionLockedOnFocusLock) { float cursorOffsetLocalLength = LineBase.GetNormalizedLengthFromWorldLength(cursorOffsetWorldLength); LineBase.LineEndClamp = 1 - cursorOffsetLocalLength; } else { // Otherwise clamp the line end by the clear distance float clearLocalLength = lineBase.GetNormalizedLengthFromWorldLength(clearWorldLength - cursorOffsetWorldLength, maxClampLineSteps); LineBase.LineEndClamp = clearLocalLength; } }
public static CategorySr CreateFromDataRow(LineBase lb, DataRow dr) { CategorySr cs = new CategorySr(); cs.FillFromDataRow(dr); return(cs); }
public static TournamentSr CreateFromDataRow(LineBase lb, DataRow dr) { TournamentSr ts = new TournamentSr(); ts.FillFromDataRow(dr); return(ts); }
public static CompetitorSr CreateFromDataRow(LineBase lb, DataRow dr) { CompetitorSr csr = new CompetitorSr(); csr.FillFromDataRow(dr); return(csr); }
public static SportSr CreateFromDataRow(LineBase lb, DataRow dr) { SportSr sport = new SportSr(); sport.FillFromDataRow(dr); return(sport); }
protected override void DrawCustomSceneGUI() { base.DrawCustomSceneGUI(); LineBase line = (LineBase)target; line.FirstPoint = SquareMoveHandle(line.FirstPoint); line.LastPoint = SquareMoveHandle(line.LastPoint); }
public static OddSr CreateFromDataRow(LineBase lb, BetDomainSr bds, DataRow dr) { OddSr os = new OddSr();//DataCopy.CreateFromDataRow<OddSr>(dr); os.m_betDomainSr = bds; os.FillFromDataRow(dr); return(os); }
protected void DrawLinePoints(LineBase line) { Handles.color = DefaultDisplayLineColor; float dotSize = HandleUtility.GetHandleSize(line.transform.position) * 0.025f; for (int i = 0; i < line.NumPoints; i++) { Handles.DotHandleCap(0, line.GetPoint(i), Quaternion.identity, dotSize, EventType.Repaint); } }
public static LanguageStringSr CreateFromDataRow(LineBase lb, string sMultiStringTag, DataRow dr) { LanguageStringSr lss = new LanguageStringSr(); lss.MultiStringTag = sMultiStringTag.ToLowerInvariant(); lss.FillFromDataRow(dr); return(lss); }
protected virtual void OnEnable() { // Get our line if it exists if (toolTipLine == null) { toolTipLine = gameObject.GetComponent <LineBase>(); } //EnforceHeirarchy(); RefreshLocalContent(); contentParent.SetActive(false); }
/// <summary> /// /// </summary> /// <returns></returns> private bool IsAllZeroLine(LineBase line) { foreach (object obj in line.Values) { LineDotValue ldv = obj as LineDotValue; if (ldv.Value != 0) { return(false); } } return(true); }
protected override void OnEnable() { base.OnEnable(); LineBase = GetComponent <LineBase>(); DistorterGravity = GetComponent <DistorterGravity>(); LineBase.AddDistorter(DistorterGravity); if (LineRenderers == null || LineRenderers.Length == 0) { LineRenderers = LineBase.GetComponentsInChildren <LineRendererBase>(); } LineBase.enabled = false; }
protected void DrawManualUpVectorHandles(LineBase line) { if (line.ManualUpVectors == null || line.ManualUpVectors.Length < 2) { line.ManualUpVectors = new Vector3[2]; } for (int i = 0; i < line.ManualUpVectors.Length; i++) { float normalizedLength = (1f / (line.ManualUpVectors.Length - 1)) * i; Vector3 currentPoint = line.GetPoint(normalizedLength); Vector3 currentUpVector = line.ManualUpVectors[i]; line.ManualUpVectors[i] = VectorHandle(currentPoint, currentUpVector, false, lineManualUpVectorLength); } }
public void InitWithPoints(Vector3[] points) { LineBase line = null; if (m_nCurrentLineIndex != -1) { line = m_Lines[m_nCurrentLineIndex]; } else { line = GetOrCreateCurrentLine(); } line.InitWithPoints(points); UpdateVisiblePoints(); }
protected void DrawDottedLine(LineBase line, int numSteps) { Vector3 firstPos = Vector3.zero; Vector3 lastPos = Vector3.zero; switch (EditorStepMode) { case StepModeEnum.FromSource: firstPos = line.GetPoint(0); lastPos = firstPos; for (int i = 1; i < line.NumPoints; i++) { Vector3 currentPos = line.GetPoint(i); Handles.DrawDottedLine(lastPos, currentPos, MRTKEditor.DottedLineScreenSpace); lastPos = currentPos; } if (line.Loops) { Handles.DrawDottedLine(lastPos, firstPos, MRTKEditor.DottedLineScreenSpace); } break; case StepModeEnum.Interpolated: default: firstPos = line.GetPoint(0f); lastPos = firstPos; Handles.color = DefaultDisplayLineColor; for (int i = 1; i < numSteps; i++) { float normalizedLength = (1f / (numSteps - 1)) * i; Vector3 currentPos = line.GetPoint(normalizedLength); Handles.DrawDottedLine(lastPos, currentPos, MRTKEditor.DottedLineScreenSpace); lastPos = currentPos; } if (line.Loops) { Handles.DrawDottedLine(lastPos, firstPos, MRTKEditor.DottedLineScreenSpace); } break; } }
/// <inheritdoc /> protected override void UpdateRays() { // Make sure our array will hold if (Rays == null || Rays.Length != LineCastResolution) { Rays = new RayStep[LineCastResolution]; } float stepSize = 1f / Rays.Length; Vector3 lastPoint = LineBase.GetUnClampedPoint(0f); for (int i = 0; i < Rays.Length; i++) { Vector3 currentPoint = LineBase.GetUnClampedPoint(stepSize * (i + 1)); Rays[i].UpdateRayStep(ref lastPoint, ref currentPoint); lastPoint = currentPoint; } }
private IEnumerator Next() { if (m_LineQueue.Count == 0) { Stop(); yield break; } yield return(null); curLine = m_LineQueue.Dequeue(); if (curLine.CheckLine()) { curLine.OnEnter(); } else { Run(); } }
public LineBase GetOrCreateCurrentLine() { LineBase line = null; if (m_nCurrentLineIndex != -1) { line = m_Lines[m_nCurrentLineIndex]; } else { line = Instantiate(lineTrunkPrefab).GetComponent <LineBase>(); line.transform.parent = m_lineTrunksParent; m_Lines.Add(line); m_nCurrentLineIndex = 0; } return(line); }
protected void DrawLineRotations(LineBase line, int numSteps) { Handles.color = lineVelocityColor; float arrowSize = HandleUtility.GetHandleSize(line.transform.position) * lineRotationLength; for (int i = 1; i < numSteps; i++) { float normalizedLength = (1f / (numSteps - 1)) * i; Vector3 currentPos = line.GetPoint(normalizedLength); Quaternion rotation = line.GetRotation(normalizedLength); Handles.color = Color.Lerp(lineVelocityColor, Handles.zAxisColor, 0.75f); Handles.ArrowHandleCap(0, currentPos, Quaternion.LookRotation(rotation * Vector3.forward), arrowSize, EventType.Repaint); Handles.color = Color.Lerp(lineVelocityColor, Handles.xAxisColor, 0.75f); Handles.ArrowHandleCap(0, currentPos, Quaternion.LookRotation(rotation * Vector3.right), arrowSize, EventType.Repaint); Handles.color = Color.Lerp(lineVelocityColor, Handles.yAxisColor, 0.75f); Handles.ArrowHandleCap(0, currentPos, Quaternion.LookRotation(rotation * Vector3.up), arrowSize, EventType.Repaint); } }
static void TaskAuthorizeProperties(LineBase bl) { if (bl.PropertyRoute.PropertyRouteType == PropertyRouteType.FieldOrProperty) { switch (PropertyAuthLogic.GetPropertyAllowed(bl.PropertyRoute)) { case PropertyAllowed.None: bl.Visible = false; break; case PropertyAllowed.Read: bl.ReadOnly = true; break; case PropertyAllowed.Modify: break; } } }
void Awake() { m_Lines = new List <LineBase>(); m_lineTrunksParent = transform.Find("trunks"); foreach (Transform t in m_lineTrunksParent) { LineBase line = t.gameObject.GetComponent <LineBase>(); if (line) { m_Lines.Add(line); } } if (m_Lines.Count > 0) { m_nCurrentLineIndex = m_Lines.Count - 1; } m_Head = transform.Find("head").gameObject; m_Tail = transform.Find("tail").gameObject; }
protected override void DrawCustomFooter() { LineBase line = (LineBase)target; if (DrawSectionStart(line.name + " Editor", "Editor Settings")) { linePreviewResolutionSelected = EditorGUILayout.IntSlider("Preview resolution", linePreviewResolutionSelected, 3, 100); drawDottedLine = EditorGUILayout.Toggle("Draw Dotted Line", drawDottedLine); drawLinePoints = EditorGUILayout.Toggle("Draw Line Points", drawLinePoints); drawLineRotations = EditorGUILayout.Toggle("Draw Line Rotations", drawLineRotations); drawLineManualUpVectors = EditorGUILayout.Toggle("Draw Manual Up Vectors", drawLineManualUpVectors); if (drawLineRotations) { lineRotationLength = EditorGUILayout.Slider("Rotation Arrow Length", lineRotationLength, 0.01f, 5f); } if (drawLineManualUpVectors) { lineManualUpVectorLength = EditorGUILayout.Slider("Manual Up Vector Length", lineManualUpVectorLength, 1f, 10f); if (GUILayout.Button("Normalize Up Vectors")) { for (int i = 0; i < line.ManualUpVectors.Length; i++) { Vector3 upVector = line.ManualUpVectors[i]; if (upVector == Vector3.zero) { upVector = Vector3.up; } line.ManualUpVectors[i] = upVector.normalized; } } } } DrawSectionEnd(); SceneView.RepaintAll(); }
public static PointF GetIntersectPoint(Idraw shape1, Idraw shape2) { Type type1 = shape1.GetType(); Type type2 = shape2.GetType(); if (type1.IsSubclassOf(typeof(LineBase)) && type2.IsSubclassOf(typeof(LineBase))) { LineBase line1 = shape1 as LineBase; LineBase line2 = shape2 as LineBase; PointF p1 = line1.__start.Location; PointF p2 = line1.__end.Location; PointF p3 = line2.__start.Location; PointF p4 = line2.__end.Location; return(LinesIntersect(p1, p2, p3, p4, false, false)); } return(PointF.Empty); }
protected override void SetLinePoints(Vector3 startPoint, Vector3 endPoint, float distance) { LineBase.FirstPoint = startPoint; LineBase.LastPoint = endPoint; if (IsFocusLocked && IsTargetPositionLockedOnFocusLock) { inertia.enabled = false; // Project forward based on pointer direction to get an 'expected' position of the first control point Vector3 expectedPoint = startPoint + Rotation * Vector3.forward * distance; // Lerp between the expected position and the expected point LineBase.SetPoint(1, Vector3.Lerp(startPoint, expectedPoint, startPointLerp)); // Get our next 'expected' position by lerping between the expected point and the end point // The result will be a line that starts moving in the pointer's direction then bends towards the target expectedPoint = Vector3.Lerp(expectedPoint, endPoint, endPointLerp); LineBase.SetPoint(2, Vector3.Lerp(startPoint, expectedPoint, endPointLerp)); } else { inertia.enabled = true; } }
public void CreateDataAsset() { LineBase line = FindObjectOfType(typeof(LineBase)) as LineBase; LineRenderer lineR = line.GetComponent <LineRenderer>(); LineDataClass lineAsset = ScriptableObject.CreateInstance <LineDataClass>(); lineAsset.points = new Vector3[lineR.positionCount]; for (int i = 0; i < lineR.positionCount; i++) { lineAsset.points[i] = lineR.GetPosition(i); } string path = "Assets/Data/Lines/"; string[] files = System.IO.Directory.GetFiles(path, "Line*.asset"); int filesCount = files.GetLength(0); string newFileName = "Line_" + filesCount + ".asset"; AssetDatabase.CreateAsset(lineAsset, path + newFileName); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = lineAsset; }
protected override void DrawCustomSceneGUI() { LineBase line = (LineBase)target; bool selected = Selection.activeGameObject == line.gameObject; int previewResolution = Mathf.Min(linePreviewResolutionSelected, linePreviewResolutionUnselected); if (selected) { previewResolution = linePreviewResolutionSelected; } // Draw dotted lines regardless of selection if (drawDottedLine) { DrawDottedLine(line, previewResolution); } // Draw rotations only on selected object if (drawLineRotations && selected) { DrawLineRotations(line, previewResolution); } // Draw up vectors only on selected object if (drawLineManualUpVectors && selected) { DrawManualUpVectorHandles(line); } if (drawLinePoints) { DrawLinePoints(line); } // Since lines are constantly updating themselves // just repaint all by default }
protected void SetDecorator(LineBase line) { Decorator headDecorator = this.HeadDecorator; Decorator decorNode = line.HeadDecorator; base.ApplyDecorator(headDecorator, decorNode); if (headDecorator != null) { decorNode.Container = line; } headDecorator = this.TailDecorator; decorNode = line.TailDecorator; base.ApplyDecorator(headDecorator, decorNode); if (headDecorator != null) { decorNode.Container = line; } }