void OnDrawGizmosSelected() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(attackPosition.position, attackRange); }
private void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, openDistance); }
void OnDrawGizmosSelected() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(swordPos.position, swordRange); }
private void OnDrawGizmos() { Gizmos.DrawLine(transform.position, transform.position + transform.forward * reachDistance); }
//assistant for turret range void OnDrawGizmosSelected() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, range); }
private void OnDrawGizmos() { Gizmos.DrawLine(pos1.position, pos2.position); }
// Called by Unity private void OnDrawGizmosSelected() { Gizmos.color = Color.magenta; Gizmos.DrawWireSphere(transform.position, chaseDistance); }
//Helpful Gizmos For Testing private void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawWireCube(transform.position, new Vector3(width, height, 0)); }
private void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawWireCube(dirPos.position, dirSize); }
void OnDrawGizmos() { Gizmos.color = Color.green; Gizmos.DrawWireSphere(transform.position, radius); }
private void OnDrawGizmos() { Gizmos.DrawLine(pointA.position, pointB.position); }
private void OnDrawGizmos() { Gizmos.DrawWireSphere(transform.position, 0.3f); }
private void OnDrawGizmosSelected() { Gizmos.DrawWireSphere(transform.position, attackRange); }
private void OnDrawGizmos() { Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius); Gizmos.DrawWireSphere(pipeCheck.position, pipeCheckRadius); Gizmos.DrawWireSphere(stickCheck.position, stickCheckRadius); }
void OnDrawGizmos()// Draws a blue circle around the candle in the editor to help visualize the disance of the interactableRange { Gizmos.color = Color.blue; Gizmos.DrawWireSphere(gameObject.transform.position, interRange); }
//------------------------------------------------------------------------------------------- void OnDrawGizmosSelected() { Gizmos.color = Color.green; Gizmos.DrawWireSphere(transform.position, minimum_Safe_Distance); }
void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawSphere(transform.position + spawnPos, 0.05f); }
private void OnDrawGizmos() { if (secondLink != null) Gizmos.DrawLine(transform.position, secondLink.transform.position); }
/** Draws the Leap Motion gizmo when in the Unity editor. */ void OnDrawGizmos() { Gizmos.matrix = Matrix4x4.Scale(GIZMO_SCALE * Vector3.one); Gizmos.DrawIcon(transform.position, "leap_motion.png"); }
void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, spawnRadius); }
private void OnDrawGizmosSelected() { Gizmos.DrawWireSphere(transform.position, blastRadius); }
void OnDrawGizmos() { Bounds bounds = CalculatePlayfieldBounds ( ); Gizmos.DrawWireCube ( bounds.center, bounds.size ); }
private void OnDrawGizmosSelected() { Gizmos.color = Color.yellow; Gizmos.DrawWireSphere(transform.position, visionRadius); Gizmos.DrawWireSphere(transform.position, attackRadius); }
private void OnDrawGizmos() { if (connectedWaypoints.Count > 0) { // Draw the sphere / cube if (isBlocked) { Gizmos.color = isCurrentPathTarget ? WaypointGizmoStyle.ColorCurrentNode : WaypointGizmoStyle.CubeColor; if (isIgnored) { Gizmos.DrawWireCube(transform.position, WaypointGizmoStyle.wireCubeSize); Gizmos.color = isCurrentPathTarget ? WaypointGizmoStyle.ColorCurrentNode : WaypointGizmoStyle.CubeIgnoredColor; } Gizmos.DrawCube(transform.position, isCurrentPathTarget ? WaypointGizmoStyle.cubeSizeCurrentNode : WaypointGizmoStyle.cubeSize); } else { Gizmos.color = isCurrentPathTarget ? WaypointGizmoStyle.ColorCurrentNode : WaypointGizmoStyle.SphereColor; if (isIgnored) { Gizmos.DrawWireSphere(transform.position, WaypointGizmoStyle.wireSphereRadius); Gizmos.color = isCurrentPathTarget ? WaypointGizmoStyle.ColorCurrentNode : WaypointGizmoStyle.SphereIgnoredColor; } Gizmos.DrawSphere(transform.position, isCurrentPathTarget ? WaypointGizmoStyle.sphereRadiusCurrentNode : WaypointGizmoStyle.nodeRadius); } if (isDynamic) { Gizmos.color = WaypointGizmoStyle.DynamicNodeColor; Gizmos.DrawSphere(transform.position, WaypointGizmoStyle.dynamicNodeRadius); } // Draw the lines and arrows foreach (var waypoint in connectedWaypoints.Where(waypoint => waypoint != null)) { var lineNormal = (waypoint.transform.position - transform.position).normalized; var offset = waypoint.IsConnectedWith(this) ? Quaternion.AngleAxis(90.0f, Vector3.up) * lineNormal * WaypointGizmoStyle.doubleLineWidth : Vector3.zero; var lineFrom = transform.position + offset; var lineTo = waypoint.transform.position + offset; var arrowAxis = Vector3.Cross(lineFrom, lineTo); var arrowDiff = lineTo - lineFrom; var arrowLength = arrowDiff.normalized * WaypointGizmoStyle.arrowSize; var arrowFrom = lineFrom + arrowDiff * Mathf.Lerp(0.35f, 0.65f, gizmosLerpT); var arrowToLeft = arrowFrom + Quaternion.AngleAxis(Mathf.Lerp(160f, 180f, gizmosLerpT), arrowAxis) * arrowLength; var arrowToRight = arrowFrom + Quaternion.AngleAxis(Mathf.Lerp(200f, 180f, gizmosLerpT), arrowAxis) * arrowLength; // The line Gizmos.color = waypoint.isBlocked ? WaypointGizmoStyle.LineBlockedColor : waypoint == nextWaypointOnPath ? WaypointGizmoStyle.PathColor : WaypointGizmoStyle.LineColor; Gizmos.DrawLine(lineFrom, lineTo); // The arrow Gizmos.color = WaypointGizmoStyle.ArrowColor; Gizmos.DrawLine(arrowFrom, arrowToLeft); Gizmos.DrawLine(arrowFrom, arrowToRight); Gizmos.DrawLine(arrowToLeft, arrowToRight); } } else // a.k.a DEAD END { Gizmos.color = WaypointGizmoStyle.ColorFaulty; Gizmos.DrawSphere(transform.position, WaypointGizmoStyle.nodeRadius); } }
/// <summary> /// Convenience function that figures out the panel's correct change flag by searching the parents. /// </summary> int GetChangeFlag(UINode start) { int flag = start.changeFlag; if (flag == -1) { Transform trans = start.trans.parent; UINode sub; // Keep going until we find a set flag for (;;) { // Check the parent's flag #if UNITY_FLASH if (mChildren.TryGetValue(trans, out sub)) { #else if (mChildren.Contains(trans)) { sub = (UINode)mChildren[trans]; #endif flag = sub.changeFlag; trans = trans.parent; // If the flag hasn't been set either, add this child to the hierarchy if (flag == -1) { mHierarchy.Add(sub); } else { break; } } else { flag = 0; break; } } // Update the parent flags for (int i = 0, imax = mHierarchy.Count; i < imax; ++i) { UINode pc = mHierarchy[i]; pc.changeFlag = flag; } mHierarchy.Clear(); } return(flag); } /// <summary> /// Update the world-to-local transform matrix as well as clipping bounds. /// </summary> void UpdateTransformMatrix() { float time = Time.realtimeSinceStartup; if (time == 0f || mMatrixTime != time) { mMatrixTime = time; mWorldToLocal = cachedTransform.worldToLocalMatrix; if (mClipping != UIDrawCall.Clipping.None) { Vector2 size = new Vector2(mClipRange.z, mClipRange.w); if (size.x == 0f) { size.x = (mCam == null) ? Screen.width : mCam.pixelWidth; } if (size.y == 0f) { size.y = (mCam == null) ? Screen.height : mCam.pixelHeight; } size *= 0.5f; mMin.x = mClipRange.x - size.x; mMin.y = mClipRange.y - size.y; mMax.x = mClipRange.x + size.x; mMax.y = mClipRange.y + size.y; } } } /// <summary> /// Run through all managed transforms and see if they've changed. /// </summary> void UpdateTransforms() { bool transformsChanged = false; #if UNITY_EDITOR bool shouldCull = !Application.isPlaying || Time.realtimeSinceStartup > mCullTime; #else bool shouldCull = Time.realtimeSinceStartup > mCullTime; #endif // Check to see if something has changed if (shouldCull) { #if UNITY_FLASH foreach (KeyValuePair <Transform, UINode> child in mChildren) { UINode node = child.Value; #else for (int i = 0, imax = mChildren.Count; i < imax; ++i) { UINode node = (UINode)mChildren[i]; #endif if (node.trans == null) { mRemoved.Add(node.trans); continue; } if (node.HasChanged()) { node.changeFlag = 1; transformsChanged = true; } else { node.changeFlag = -1; } } // Clean up the deleted transforms for (int i = 0, imax = mRemoved.Count; i < imax; ++i) { mChildren.Remove(mRemoved[i]); } mRemoved.Clear(); } // If the children weren't culled but should be, check their visibility if (!mCulled && shouldCull) { mCheckVisibility = true; } // If something has changed, propagate the changes *down* the tree hierarchy (to children). // An alternative (but slower) approach would be to do a pc.trans.GetComponentsInChildren<UIWidget>() // in the loop above, and mark each one as dirty. if (mCheckVisibility || transformsChanged || mRebuildAll) { #if UNITY_FLASH foreach (KeyValuePair <Transform, UINode> child in mChildren) { UINode pc = child.Value; #else for (int i = 0, imax = mChildren.Count; i < imax; ++i) { UINode pc = (UINode)mChildren[i]; #endif if (pc.widget != null) { int visibleFlag = 1; // No sense in checking the visibility if we're not culling anything (as the visibility is always 'true') if (shouldCull) { // If the change flag has not yet been determined... if (pc.changeFlag == -1) { pc.changeFlag = GetChangeFlag(pc); } // Is the widget visible? visibleFlag = (mCheckVisibility || pc.changeFlag == 1) ? (IsVisible(pc.widget) ? 1 : 0) : pc.visibleFlag; } // If visibility changed, mark the node as changed as well if (pc.visibleFlag != visibleFlag) { pc.changeFlag = 1; } // If the node has changed and the widget is visible (or was visible before) if (pc.changeFlag == 1 && (visibleFlag == 1 || pc.visibleFlag != 0)) { // Update the visibility flag pc.visibleFlag = visibleFlag; Material mat = pc.widget.material; // Add this material to the list of changed materials if (!mChanged.Contains(mat)) { mChanged.Add(mat); } } } } } mCulled = shouldCull; mCheckVisibility = false; } /// <summary> /// Update all widgets and rebuild their geometry if necessary. /// </summary> void UpdateWidgets() { #if UNITY_FLASH foreach (KeyValuePair <Transform, UINode> c in mChildren) { UINode pc = c.Value; #else for (int i = 0, imax = mChildren.Count; i < imax; ++i) { UINode pc = (UINode)mChildren[i]; #endif UIWidget w = pc.widget; // If the widget is visible, update it if (pc.visibleFlag == 1 && w != null && w.UpdateGeometry(ref mWorldToLocal, (pc.changeFlag == 1), generateNormals)) { // We will need to refill this buffer if (!mChanged.Contains(w.material)) { mChanged.Add(w.material); } } pc.changeFlag = 0; } } /// <summary> /// Update the clipping rect in the shaders and draw calls' positions. /// </summary> public void UpdateDrawcalls() { Vector4 range = Vector4.zero; if (mClipping != UIDrawCall.Clipping.None) { range = new Vector4(mClipRange.x, mClipRange.y, mClipRange.z * 0.5f, mClipRange.w * 0.5f); } if (range.z == 0f) { range.z = Screen.width * 0.5f; } if (range.w == 0f) { range.w = Screen.height * 0.5f; } RuntimePlatform platform = Application.platform; if (platform == RuntimePlatform.WindowsPlayer || platform == RuntimePlatform.WindowsWebPlayer || platform == RuntimePlatform.WindowsEditor) { range.x -= 0.5f; range.y += 0.5f; } Transform t = cachedTransform; for (int i = 0, imax = mDrawCalls.Count; i < imax; ++i) { UIDrawCall dc = mDrawCalls[i]; dc.clipping = mClipping; dc.clipRange = range; dc.clipSoftness = mClipSoftness; dc.depthPass = depthPass; // Set the draw call's transform to match the panel's. // Note that parenting directly to the panel causes unity to crash as soon as you hit Play. Transform dt = dc.transform; dt.position = t.position; dt.rotation = t.rotation; dt.localScale = t.lossyScale; } } /// <summary> /// Set the draw call's geometry responsible for the specified material. /// </summary> void Fill(Material mat) { // Cleanup deleted widgets for (int i = mWidgets.Count; i > 0;) { if (mWidgets[--i] == null) { mWidgets.RemoveAt(i); } } // Fill the buffers for the specified material for (int i = 0, imax = mWidgets.Count; i < imax; ++i) { UIWidget w = mWidgets[i]; if (w.visibleFlag == 1 && w.material == mat) { UINode node = GetNode(w.cachedTransform); if (node != null) { if (generateNormals) { w.WriteToBuffers(mVerts, mUvs, mCols, mNorms, mTans); } else { w.WriteToBuffers(mVerts, mUvs, mCols, null, null); } } else { Debug.LogError("No transform found for " + NGUITools.GetHierarchy(w.gameObject), this); } } } if (mVerts.size > 0) { // Rebuild the draw call's mesh UIDrawCall dc = GetDrawCall(mat, true); dc.depthPass = depthPass; dc.Set(mVerts, generateNormals ? mNorms : null, generateNormals ? mTans : null, mUvs, mCols); } else { // There is nothing to draw for this material -- eliminate the draw call UIDrawCall dc = GetDrawCall(mat, false); if (dc != null) { mDrawCalls.Remove(dc); NGUITools.DestroyImmediate(dc.gameObject); } } // Cleanup mVerts.Clear(); mNorms.Clear(); mTans.Clear(); mUvs.Clear(); mCols.Clear(); } /// <summary> /// Main update function /// </summary> void LateUpdate() { UpdateTransformMatrix(); UpdateTransforms(); // Always move widgets to the panel's layer if (mLayer != gameObject.layer) { mLayer = gameObject.layer; UICamera uic = UICamera.FindCameraForLayer(mLayer); mCam = (uic != null) ? uic.cachedCamera : NGUITools.FindCameraForLayer(mLayer); SetChildLayer(cachedTransform, mLayer); for (int i = 0, imax = drawCalls.Count; i < imax; ++i) { mDrawCalls[i].gameObject.layer = mLayer; } } UpdateWidgets(); // If the depth has changed, we need to re-sort the widgets if (mDepthChanged) { mDepthChanged = false; mWidgets.Sort(UIWidget.CompareFunc); } // Fill the draw calls for all of the changed materials for (int i = 0, imax = mChanged.Count; i < imax; ++i) { Fill(mChanged[i]); } // Update the clipping rects UpdateDrawcalls(); mChanged.Clear(); mRebuildAll = false; #if UNITY_EDITOR mScreenSize = new Vector2(Screen.width, Screen.height); #endif } #if UNITY_EDITOR /// <summary> /// Draw a visible pink outline for the clipped area. /// </summary> void OnDrawGizmos() { if (mDebugInfo == DebugInfo.Gizmos && mClipping != UIDrawCall.Clipping.None) { Vector2 size = new Vector2(mClipRange.z, mClipRange.w); if (size.x == 0f) { size.x = mScreenSize.x; } if (size.y == 0f) { size.y = mScreenSize.y; } Gizmos.matrix = transform.localToWorldMatrix; Gizmos.color = Color.magenta; Gizmos.DrawWireCube(new Vector2(mClipRange.x, mClipRange.y), size); } }
private void OnDrawGizmosSelected() { Gizmos.DrawWireSphere(firepoint.position, attackrange); }
void OnDrawGizmos() { Gizmos.color = gizmoColor; Gizmos.DrawSphere(transform.position, transform.localScale.x); }
void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawRay(characterOffest + Rig.position, Vector2.down); }
private void OnDrawGizmosSelected() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, targetCheckRadius); }
public void DrawGizmos() { Gizmos.DrawLine(ourTransform.position, behaviour.initialPosition); }