// Shows and handles point handle private Vector3 ShowPoint(int index) { // Get point from curve at given index, and convert it to transforms space Vector3 point = handleTransform.TransformPoint(spline.GetPoint(index)); // Show position handles if (selectedIndex == index || ShowPositionHandles) { // Assing handle position back to point on curve EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, handleRotation); if (EditorGUI.EndChangeCheck()) { // Before making change, record state // and set state to changed/dirty Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); // Transform from world space back to lines' local space spline.SetPoint(index, handleTransform.InverseTransformPoint(point)); } } // Show custom handles else { // Handle settings Handles.color = modeColors[(int)spline.GetPointMode(index)]; float size = HandleUtility.GetHandleSize(point); float handleSize = (index % 3 == 0) ? handleSizePoint : handleSizeAnchor; // Select handle if (Handles.Button(point, handleRotation, size * handleSize, size * pickSize, Handles.DotCap)) { selectedIndex = index; Repaint(); } } return(point); }
public void Draw() { Handles.DrawBezier( inPoint.rect.center, outPoint.rect.center, inPoint.rect.center + Vector2.left * 50f, outPoint.rect.center - Vector2.left * 50f, Color.white, null, 2f ); Vector3 centerPos = (inPoint.rect.center + outPoint.rect.center) * 0.5f; if (Handles.Button(centerPos, Quaternion.identity, 5, 8, Handles.RectangleHandleCap)) { if (OnClickRemoveConnection != null) { OnClickRemoveConnection(this); } } }
public void Draw() { Debug.Log(inPoint.data); Debug.Log(outPoint.data); Handles.DrawBezier( inPoint.rect.center, outPoint.rect.center, inPoint.rect.center + Vector2.left * 50f, outPoint.rect.center - Vector2.left * 50f, Color.white, null, 2f ); if (Handles.Button((inPoint.rect.center + outPoint.rect.center) * 0.5f, Quaternion.identity, 4, 8, Handles.RectangleCap)) { if (OnClickRemoveConnection != null) { OnClickRemoveConnection(this); } } }
public void Draw(SDFEditor editor) { Rect outRect = outPoint.GetRect(); Rect inRect = inPoint.GetRect(); Handles.DrawBezier( outRect.center, inRect.center, outRect.center + Vector2.left * 50f, inRect.center - Vector2.left * 50f, Color.white, null, 2f ); if (Handles.Button((inRect.center + outRect.center) * 0.5f, Quaternion.identity, 4, 8, Handles.RectangleHandleCap)) { OnClickRemoveConnection?.Invoke(this); editor.OnClickRemoveConnection(this); } }
/// <summary>Draws a button used for inserting a node at the start of the rail</summary> /// <param name="rail">The rail to insert a node at the start of</param> /// <param name="snapActive">Indicates whether positioning should snap to a grid</param> /// <param name="handleSize">Handle size</param> public static void DrawRailNodeInsertAtStartButton(Rail rail, bool snapActive, float handleSize, float snapSize) { var buttonSize = 0.25f * handleSize; var buttonOffsetVector = handleSize * 1.5f; if (snapActive) { buttonOffsetVector = Mathf.Round(buttonOffsetVector / snapSize) * snapSize; if (buttonOffsetVector < snapSize) { buttonOffsetVector = snapSize; } } var buttonPosition = rail.Nodes[0].Position - new Vector2(buttonOffsetVector, buttonOffsetVector); if (Handles.Button(buttonPosition, Quaternion.identity, buttonSize, buttonSize, Handles.RectangleHandleCap)) { InsertRailNode(rail, 0, buttonPosition); } }
private Vector3 ShowPoint(int index) { Vector3 point = handleTransform.TransformPoint(spline.GetControlPoint(index)); Handles.color = modeColors[(int)spline.GetControlPointMode(index)]; float size = HandleUtility.GetHandleSize(point); if (Handles.Button(point, handleRotation, size * handleSize, size * pickSize, Handles.DotCap)) { selectedIndex = index; Repaint(); } if (selectedIndex == index) { EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, handleRotation); Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); spline.SetControlPoint(index, handleTransform.InverseTransformPoint(point)); } return(point); }
void DrawNode(Node node, int nodeIndex) { if (Handles.Button(node.position, Quaternion.identity, .3f, .4f, Handles.SphereCap)) { if (isLinking && selectedNode != null) { AudioPropagateNodeGroup pGroup = (AudioPropagateNodeGroup)target; pGroup.ConnectNodes(selectedNode, node); isLinking = false; } selectedNode = node; } //Handles.Label(node.position, node.id.ToString()); for (int i = 0; i < node.connections.Count; ++i) { var otherNode = node.connections[i]; Handles.DrawLine(node.position, otherNode.position); } }
void DrawSelectionHandles(int i) { if (Event.current.button != 1 && selectedIndex != i) { if (waypointTranslateMode == CPC_EManipulationModes.SelectAndTransform && Tools.current == Tool.Move || waypointRotationMode == CPC_EManipulationModes.SelectAndTransform && Tools.current == Tool.Rotate) { float size = HandleUtility.GetHandleSize(t.points[i].position) * 0.2f; #if UNITY_5_5_OR_NEWER if (Handles.Button(t.points[i].position, Quaternion.identity, size, size, Handles.CubeHandleCap)) { SelectIndex(i); } #else if (Handles.Button(t.points[i].position, Quaternion.identity, size, size, Handles.CubeCap)) { SelectIndex(i); } #endif } } }
void OnSceneGUI() { Grid comp = (Grid)target; if (comp.IsInitialized) { Vector3 cellSize = comp.GetCellSize(); int xDim, yDim; comp.GetDimensions(out xDim, out yDim); float size = Mathf.Min(cellSize.x, Mathf.Min(cellSize.y, cellSize.z)) * 0.5f; for (int y = 0; y < yDim; y++) { for (int x = 0; x < xDim; x++) { if (comp.IsCellShown(x, y)) { continue; } Vector3 pos = comp.GetWorldCellPosition(x, y); if (comp.IsSelected(x, y)) { Handles.color = new Color(1.0f, 0.5f, 0.0f); Vector3 newPos = Handles.Slider(pos, comp.transform.up); float heightAdj = Vector3.Dot(comp.transform.up, newPos - pos); comp.SetCellHeight(x, y, comp.GetCellHeight(x, y) + heightAdj); Handles.color = new Color(0.0f, 1.0f, 1.0f, 0.1f); } else { Handles.color = new Color(1.0f, 1.0f, 1.0f, 0.1f); } if (Handles.Button(pos, comp.transform.rotation, size, size, Handles.CubeCap)) { comp.SetSelected(x, y); } } } } }
//Draw line to squad trigger's position public static void ShowAlignedSquadTriggerAxis(SquadManager squadManager) { Handles.color = Color.white; //Spawn button marker at location of squad if (Handles.Button(squadManager.transform.position, Quaternion.identity, 0.10f, 0.10f, Handles.DotCap)) { //Make squad active GameObject in Hierarchy Selection.activeGameObject = squadManager.gameObject; } Vector3[] squadTriggerPositions = new Vector3[squadManager.SquadTriggers.Count + 1]; squadTriggerPositions[0] = squadManager.transform.position; for (int i = 0; i < squadManager.SquadTriggers.Count; i++) { squadTriggerPositions[i + 1] = squadManager.SquadTriggers[i].transform.position; } Handles.DrawPolyLine(squadTriggerPositions); }
public void Draw() { #if UNITY_EDITOR_WIN Handles.DrawBezier( inPoint.rect.center, outPoint.rect.center, inPoint.rect.center + Vector2.left * 50f, outPoint.rect.center - Vector2.left * 50f, Color.white, null, 2f ); if (Handles.Button((inPoint.rect.center + outPoint.rect.center) * 0.5f, Quaternion.identity, 4, 8, Handles.RectangleCap)) { if (OnClickRemoveConnection != null) { OnClickRemoveConnection(this); } } #endif }
private void OnSceneGUI() { dnp = target as DebugNearestPoint; handleTransform = dnp.transform; handleRotation = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity; SplineLine spline = dnp.spline; Vector3 position = dnp.transform.position; Vector3 nearestPoint = spline.GetNearestPointOnSpline(position); //Vector3 nearestPoint = spline.GetNextControlPoint(0); Debug.Log(nearestPoint.ToString()); float size = HandleUtility.GetHandleSize(position); //spline.transform.TransformPoint(nearestPoint) Handles.DrawLine(nearestPoint, position); Handles.Button(nearestPoint, Quaternion.identity, size * handleSize, size * pickSize, Handles.DotHandleCap); }
private void OnSceneGUI() { Snap snap = (Snap)target; if (snap.extendedEditor == false) { return; } //Handles.ArrowHandleCap(0, Zposition, Quaternion.Euler(Vector3.right), 1, EventType.ContextClick); //Rotation around X axis. Button along Z axis. Vector3 Zposition = snap.transform.localPosition + Vector3.up * 1f; float size = .5f; float pickSize = size * 2f; if (Handles.Button(Zposition, Quaternion.identity, size, pickSize, Handles.CircleHandleCap)) { snap.transform.Rotate(Vector3.back, 90, Space.World); } //Rotation around Y axis. Button along X axis. Vector3 Xposition = snap.transform.localPosition + Vector3.right * 1f; if (Handles.Button(Xposition, Quaternion.Euler(Vector3.right * 90), size, pickSize, Handles.CircleHandleCap)) { snap.transform.Rotate(Vector3.down, 90, Space.World); } //Rotation around X axis. Button along Z axis. Vector3 Yposition = snap.transform.localPosition + Vector3.forward * 1f; if (Handles.Button(Yposition, Quaternion.Euler(Vector3.up * 90), size, pickSize, Handles.CircleHandleCap)) { snap.transform.Rotate(Vector3.left, 90, Space.World); } }
private void DrawPreviousHandleForWaypointIndex(int index) { if (index > 0) { EditorGUI.BeginChangeCheck(); Vector3 posPrev = Vector3.zero; float size = HandleUtility.GetHandleSize(path.points[index].position + path.points[index].handlePrev) * 0.1f; if (path.handleManipulationMode == PC_ManipulationModes.Free) { posPrev = Handles.FreeMoveHandle(path.points[index].position + path.points[index].handlePrev, Quaternion.identity, 0.1f * HandleUtility.GetHandleSize(path.points[index].position + path.points[index].handlePrev), Vector3.zero, Handles.SphereHandleCap); } else { if (selectedIndex == index) { Handles.SphereHandleCap(0, path.points[index].position + path.points[index].handlePrev, Quaternion.identity, 0.1f * HandleUtility.GetHandleSize(path.points[index].position + path.points[index].handleNext), EventType.Repaint); posPrev = Handles.PositionHandle(path.points[index].position + path.points[index].handlePrev, Quaternion.identity); } else if (Event.current.button != 1) { if (Handles.Button(path.points[index].position + path.points[index].handlePrev, Quaternion.identity, size, size, Handles.CubeHandleCap)) { SelectIndex(index); } } } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Handle Position"); path.points[index].handlePrev = posPrev - path.points[index].position; path.points[index].handleNext = path.points[index].handlePrev * -1; // always chained behaviour } } }
private void HandleSceneVertexPainting() { bool hasChanged = false; Color handlesColor = Handles.color; foreach (VertexColor vertexColor in m_vertexColors) { Vector3 pos = vertexColor.GetPosition(m_meshFilter.transform.localToWorldMatrix); Color col = vertexColor.GetColor(); Handles.color = new Color(col.r, col.g, col.b, Mathf.Lerp(MIN_VISUAL_ALPHA, 1, col.a)); if (Handles.Button(pos, Quaternion.identity, m_dotSize, m_dotSize, Handles.DotHandleCap)) { vertexColor.SetColorWithMask(m_colorMask, m_paintColor); hasChanged = true; } } if (hasChanged) { ApplyVertexColorsToMesh(); } Handles.color = handlesColor; }
public static void DrawRecognizableRect(EnemyOutsideInfo eOutsideInfo) { Handles.color = new Color(0.7f, 0f, 0f, 0.05f); Handles.DrawSolidArc( eOutsideInfo.actor.transform.position, Vector3.up, eOutsideInfo.lookDirection, eOutsideInfo.viewAngle * 0.5f, eOutsideInfo.viewRecognizeDistance); Handles.DrawSolidArc( eOutsideInfo.actor.transform.position, Vector3.down, eOutsideInfo.lookDirection, eOutsideInfo.viewAngle * 0.5f, eOutsideInfo.viewRecognizeDistance); var arcPoint = eOutsideInfo.actor.transform.position + eOutsideInfo.lookDirection * eOutsideInfo.viewRecognizeDistance; var size = HandleUtility.GetHandleSize(arcPoint); Handles.color = Color.white; if (Handles.Button(arcPoint, Quaternion.identity, size * handleSize, pickSize, Handles.DotHandleCap)) { selectedIndex = 2; } if (selectedIndex == 2) { EditorGUI.BeginChangeCheck(); arcPoint = Handles.DoPositionHandle(arcPoint, Quaternion.identity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(eOutsideInfo, "Change Radius"); EditorUtility.SetDirty(eOutsideInfo); eOutsideInfo.lookDirection = (arcPoint - eOutsideInfo.actor.transform.position).normalized; eOutsideInfo.viewRecognizeDistance = Vector3.Distance(eOutsideInfo.transform.position, arcPoint); } } }
private static void DrawIKTargets() { foreach (QuickIKManagerExecuteInEditMode ikManagerEditor in _ikManagers) { QuickIKManager ikManager = ikManagerEditor._ikManager; if (ikManager && ikManager.gameObject.activeInHierarchy) { for (IKBone ikBone = 0; ikBone < IKBone.LastBone; ikBone++) { QuickIKSolver ikSolver = ikManager.GetIKSolver(ikBone); float size; if (ikBone >= IKBone.Hips && ikBone <= IKBone.RightFoot) { size = 0.05f; } else { size = 0.01f; } Handles.color = new Color(1, 0, 0, 0.5f); if (Handles.Button(ikSolver._targetLimb.position, ikSolver._targetLimb.rotation, size, size, Handles.CubeHandleCap)) { SelectIKTarget(ikSolver._targetLimb, ikSolver, ikBone); } if (ikSolver._targetHint) { Handles.color = new Color(0, 1, 0, 0.5f); if (Handles.Button(ikSolver._targetHint.position, ikSolver._targetHint.rotation, size, size, Handles.SphereHandleCap)) { SelectIKTarget(ikSolver._targetHint, ikSolver, ikBone); } } } } } }
private Vector3 ShowPoint(int index) { Vector3 point = handleTransform.TransformPoint(spline.GetControlPoint(index)); float size = HandleUtility.GetHandleSize(point); //First point has different size if (index == 0) { size *= 2f; } else { //Mid point also has different size if (index % 3 == 0) { size *= 1.5f; } } Handles.color = modeColors[(int)spline.GetControlPointMode(index)]; if (Handles.Button(point, handleRotation, size * handleSize, size * pickSize, Handles.DotHandleCap)) { selectedIndex = index; Repaint(); } if (selectedIndex == index) { EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, handleRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); spline.SetControlPoint(index, handleTransform.InverseTransformPoint(point)); } } return(point); }
private void OnSceneGUI() { Wave[] waves = ((WaveSpawner)target).waves; for (int i = 0; i < waves.Length; i++) { Wave wave = waves[i]; for (int j = 0; j < wave.enemies.Length; j++) { WaveEnemies enemy = wave.enemies[j]; enemy.Position = Handles.PositionHandle(enemy.Position, Quaternion.identity); switch (enemy.color) { case BasicEnemy.EnemyColor.red: Handles.color = Color.red; break; case BasicEnemy.EnemyColor.green: Handles.color = Color.green; break; case BasicEnemy.EnemyColor.blue: Handles.color = Color.blue; break; } if (Handles.Button(enemy.Position, Quaternion.identity, 0.5f, 0.5f, Handles.DotHandleCap)) { enemy.color = (BasicEnemy.EnemyColor)((((int)enemy.color) + 1) % 3); } Handles.Label(enemy.Position, i.ToString()); wave.enemies[j] = enemy; } waves[i] = wave; } ((WaveSpawner)target).waves = waves; }
Vector3 ShowPoint(int idx) { // convert to world space since handles are in local space Vector3 point = _splineT.TransformPoint(_spline.GetControlPoint(idx)); Handles.color = Color.white; float size = HandleUtility.GetHandleSize(point); if (idx == 0) { size *= 2f; } Handles.color = modeColors[(int)_spline.GetControlPointMode(idx)]; // If this point is selected if (Handles.Button(point, _splineR, size * HANDLE_SIZE, size * PICK_SIZE, Handles.DotCap)) { _selectedIndex = idx; Repaint(); } // If point is selected and position is changed if (_selectedIndex == idx) { EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, _splineR); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_spline, "Move Point"); EditorUtility.SetDirty(_spline); // convert back to local space _spline.SetControlPoint(idx, _splineT.InverseTransformPoint(point)); } } return(point); }
private Vector3 ShowPoint(int index) { Vector3 point = m_HandleTransform.TransformPoint(m_Spline.GetControlPoint(index)); Handles.color = Color.yellow; //Show buttons when this point isn't selected float size = HandleUtility.GetHandleSize(point); //Makes sure they are always the same scale (independant of the camera) size *= 2.0f; if (index == 0) { size *= 2.0f; } if (Handles.Button(point, m_HandleRotation, size * c_HandleSize, size * c_PickSize, Handles.DotCap)) { m_SelectedIndex = index; Repaint(); //Makes sure the inspector updates } //Show a fully fledged handle when we're selected if (m_SelectedIndex == index) { EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, m_HandleRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_Spline, "Move Point"); //Makes sure we can undo EditorUtility.SetDirty(m_Spline); //Makes sure unity asks us to save after changing m_Spline.SetPoint(index, m_HandleTransform.InverseTransformPoint(point)); } } return(point); }
void OnSceneGUI() { if (skin != null && skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && skin.controlPoints != null && skin.controlPoints.Length > 0 && skin.points != null) { Event e = Event.current; Handles.matrix = skin.transform.localToWorldMatrix; EditorGUI.BeginChangeCheck(); Ray r = HandleUtility.GUIPointToWorldRay(e.mousePosition); Vector2 mousePos = r.origin; float selectDistance = HandleUtility.GetHandleSize(mousePos) * baseSelectDistance; #region Draw vertex handles Handles.color = handleColor; for (int i = 0; i < skin.controlPoints.Length; i++) { if (Handles.Button(skin.points.GetPoint(skin.controlPoints[i]), Quaternion.identity, selectDistance, selectDistance, Handles.CircleCap)) { selectedIndex = i; } if (selectedIndex == i) { EditorGUI.BeginChangeCheck(); skin.controlPoints[i].position = Handles.DoPositionHandle(skin.points.GetPoint(skin.controlPoints[i]), Quaternion.identity); if (EditorGUI.EndChangeCheck()) { skin.points.SetPoint(skin.controlPoints[i]); Undo.RecordObject(skin, "Changed Control Point"); Undo.RecordObject(skin.points, "Changed Control Point"); EditorUtility.SetDirty(this); } } } #endregion } }
private VertexData ShowVertexEditSceneUI(VertexData vertexData, int index) { Vector3 pos = handleTransform.TransformPoint(vertexData.GetPosition()); Handles.color = Color.white; float size = HandleUtility.GetHandleSize(pos); Handles.Label(pos + 0.6f * size * Vector3.up, "" + index); if (Handles.Button(pos, handleRotation, 1.2f * size * handleSize, 1.2f * size * pickSize, Handles.DotCap)) { vertexData.isEditMode = true; selectedVertexIndex = index; } if (vertexData.isEditMode) { EditorGUI.BeginChangeCheck(); pos = Handles.DoPositionHandle(pos, handleRotation); pos = handleTransform.InverseTransformPoint(pos); vertexData.positionX = pos.x; vertexData.positionY = pos.y; vertexData.positionZ = pos.z; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(meshEditor, "Move vertex"); EditorUtility.SetDirty(meshEditor); } } return(vertexData); }
private Vector3 ShowPoint(int index) { Vector3 point = handleTransform.TransformPoint(spline.GetControlPoint(index)); float size = HandleUtility.GetHandleSize(point); if (index % 3 == 0) { size *= (handleSize * 1.5f); } else { size *= handleSize; } EditorGUI.BeginChangeCheck(); Handles.color = modeColors[(int)spline.GetControlPointMode(index)]; if (Handles.Button(point, handleRotation, size, size, Handles.SphereHandleCap)) { selectedIndex = index; } if (index == selectedIndex) { point = Handles.DoPositionHandle(point, handleRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); spline.SetControlPoint(index, handleTransform.InverseTransformPoint(point)); } Repaint(); } return(point); }
void ShowHandle(int index) { Vector3 point = handleTransform.TransformPoint(mesh.oVertices[index]); // Unselected vertex if (!mesh.selectedIndices.Contains(index)) { Handles.color = Color.blue; if (Handles.Button(point, handleRotation, mesh.pickSize, mesh.pickSize, Handles.DotHandleCap)) { selectedIndex = index; } if (selectedIndex == index) { if (assignIndex != index) { assignIndex = mesh.targetIndex = index; mesh.selectedIndices.Add(index); } } } }
void DrawPointOptionsButton(string pointType, Vector3 position, int pointIdx, Color colour) { float size = 0.5f; Handles.color = colour; if (Handles.Button(position, Quaternion.identity, size, size, Handles.CubeHandleCap)) { switch (pointType) { case "Start Station": curveCreator.curves[selectionInfo.curveSelected].FirstStationIdx = pointIdx; break; case "Intermediate": curveCreator.curves[selectionInfo.curveSelected].IntermediatePointIdx = pointIdx; break; case "End Station": curveCreator.curves[selectionInfo.curveSelected].SecondStationIdx = pointIdx; break; } } }
private Vector3 ShowPoint(int index) { Vector3 point = handleTransform.TransformPoint(spline.points[index]); float size = HandleUtility.GetHandleSize(point); Handles.color = Color.white; if (Handles.Button(point, handleRotation, size * handleSize, size * pickSize, Handles.DotCap)) { selectedIndex = index; } if (selectedIndex == index) { EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, handleRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); spline.points[index] = handleTransform.InverseTransformPoint(point); } } return(point); }
private Vector2 SetTangentGizmo(ref Vector2 tangent, SelectedCurveUI requestedUI) { Handles.color = Color.white; Vector2 point = handleTransform.TransformPoint(tangent); if (Handles.Button(point, handleRotation, handleSize, pickSize, Handles.DotHandleCap)) { selectedUI = requestedUI; } if (selectedUI == requestedUI) { EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, handleRotation); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(node); tangent = handleTransform.InverseTransformPoint(point); } } Handles.DrawLine(point, node.transform.position); return(point); }
//Draw Scene Functions /* * private void DrawInstanModifier(string name, ref InstanModifier property, ref GameObject gOProperty) * { * if(gOProperty != null) * { * EditorGUI.BeginChangeCheck(); * InstanModifier propertyTemp = (InstanModifier)EditorGUILayout.ObjectField(name, property, typeof(InstanModifier)); * if (EditorGUI.EndChangeCheck()) * { * Undo.RecordObject(instan, name + " change"); * EditorUtility.SetDirty(instan); * property = propertyTemp; * } * if (propertyTemp != null) * { * propertyTemp.AddGUI(instan, gOProperty); * } * } * } */ private void DrawSceneHandle(string name, ref Vector3 position, ref bool isSelected) { Vector3 positionTemp = handleTransform.TransformPoint(position); float size = HandleUtility.GetHandleSize(positionTemp); Handles.color = Color.white; if (Handles.Button(positionTemp, handleRotation, size * handleSize, size * pickSize, Handles.DotHandleCap)) { isSelected = true; Repaint(); } if (isSelected) { EditorGUI.BeginChangeCheck(); positionTemp = Handles.DoPositionHandle(positionTemp, handleRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(instan, name + " change"); EditorUtility.SetDirty(instan); position = handleTransform.InverseTransformPoint(positionTemp); } } }
private void DrawGroupingHandles() { foreach (var intractableSpike in LevelEditor.AllItems[(int)ItemCategories.Intractable]) { var spike = intractableSpike.GetComponent <Game.Items.Intractable.Spike.Spike>(); if (spike == null) { continue; } Handles.color = new Color(0.25f, 1f, 0.67f); if (!spike.itemSet) { if (Handles.Button(intractableSpike.transform.position + intractableSpike.transform.up * 0.2f, Quaternion.identity, 0.15f, 0.15f, Handles.CubeCap)) { spike.itemSet = true; spike.groupId = _currentGroupId; spike.spikeId = _currentSpikeId; spike.type = _spike.type; _currentSpikeId++; } } } }