/// <summary> /// Get a float property. /// </summary> /// <param name="name">Name of the value.</param> /// <param name="defaultValue">Default value of the property if it isn't set.</param> public float GetFloat(string name, float defaultValue = 0.0f) { var systemValue = EditorPrefs.GetFloat(name, defaultValue: defaultValue); return(UseProjectSettings ? Get(name, systemValue) : systemValue); }
public EditorVariableFloat(string name, string labelName, float defaultValue) : base(name, labelName, defaultValue) { m_value = EditorPrefs.GetFloat(name, m_defaultValue); }
void OnSceneGUI() { var proCamera2DRails = (ProCamera2DRails)target; // Return if less than 2 nodes var nodesCount = proCamera2DRails.RailNodes.Count; if (nodesCount < 2) { return; } // Detect delete mode bool deleteMode = false; Event e = Event.current; if (e.alt) { deleteMode = true; } // Handles color Handles.color = EditorPrefsX.GetColor(PrefsData.RailsColorKey, PrefsData.RailsColorValue); // Draw line between nodes Handles.DrawPolyLine(proCamera2DRails.RailNodes.ToArray()); // Handle size float handleSize = HandleUtility.GetHandleSize(Vector3.zero) * .1f; // Draw left and right handles var rightHandlePos = (proCamera2DRails.RailNodes[nodesCount - 1] - proCamera2DRails.RailNodes[nodesCount - 2]).normalized * .5f + proCamera2DRails.RailNodes[nodesCount - 1]; if (Handles.Button( rightHandlePos, Quaternion.identity, handleSize * .5f, handleSize, #if UNITY_5_5_OR_NEWER Handles.RectangleHandleCap)) #else Handles.RectangleCap)) #endif { Undo.RecordObject(proCamera2DRails, "Add"); proCamera2DRails.RailNodes.Insert(nodesCount, rightHandlePos); } var leftHandlesPos = (proCamera2DRails.RailNodes[0] - proCamera2DRails.RailNodes[1]).normalized * .5f + proCamera2DRails.RailNodes[0]; if (Handles.Button( leftHandlesPos, Quaternion.identity, handleSize * .5f, handleSize, #if UNITY_5_5_OR_NEWER Handles.RectangleHandleCap)) #else Handles.RectangleCap)) #endif { Undo.RecordObject(proCamera2DRails, "Add"); proCamera2DRails.RailNodes.Insert(0, leftHandlesPos); } // Snap value var pointSnap = Vector3.one * EditorPrefs.GetFloat("RailsSnapping", PrefsData.RailsSnapping); // Draw a handle for each node for (int i = 0; i < nodesCount; i++) { var oldPos = proCamera2DRails.RailNodes[i]; var newPos = Handles.FreeMoveHandle( oldPos, Quaternion.identity, handleSize, pointSnap, #if UNITY_5_5_OR_NEWER Handles.DotHandleCap); #else Handles.DotCap); #endif // Move if (newPos != oldPos) { newPos.x = Handles.SnapValue(newPos.x, pointSnap.x); newPos.y = Handles.SnapValue(newPos.y, pointSnap.y); newPos.z = Handles.SnapValue(newPos.z, pointSnap.z); Undo.RecordObject(proCamera2DRails, "Move"); proCamera2DRails.RailNodes[i] = VectorHV(Vector3H(newPos), Vector3V(newPos)); } // Draw the midpoint button if (i > 0) { var midPoint = Vector3.Lerp(proCamera2DRails.RailNodes[i - 1], proCamera2DRails.RailNodes[i], 0.5f); if (Handles.Button( midPoint, Quaternion.identity, handleSize * .5f, handleSize, #if UNITY_5_5_OR_NEWER Handles.RectangleHandleCap)) #else Handles.RectangleCap)) #endif { Undo.RecordObject(proCamera2DRails, "Add"); proCamera2DRails.RailNodes.Insert(i, midPoint); } } // Draw the delete button if (deleteMode && nodesCount > 2) { Handles.color = Color.red; var deleteButtonPos = proCamera2DRails.RailNodes[i]; if (Handles.Button( deleteButtonPos, Quaternion.identity, handleSize, handleSize, #if UNITY_5_5_OR_NEWER Handles.DotHandleCap)) #else Handles.DotCap)) #endif { Undo.RecordObject(proCamera2DRails, "Remove"); proCamera2DRails.RailNodes.RemoveAt(i); return; } Handles.color = EditorPrefsX.GetColor(PrefsData.RailsColorKey, PrefsData.RailsColorValue); } } }
public static bool LoadPreferences() { _gridColorX = (EditorPrefs.HasKey("gridColorX")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorX")) : GRID_COLOR_X; _gridColorY = (EditorPrefs.HasKey("gridColorY")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorY")) : GRID_COLOR_Y; _gridColorZ = (EditorPrefs.HasKey("gridColorZ")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorZ")) : GRID_COLOR_Z; _alphaBump = (EditorPrefs.HasKey("pg_alphaBump")) ? EditorPrefs.GetFloat("pg_alphaBump") : ALPHA_BUMP; _snapMethod = System.Convert.ToInt32( (EditorPrefs.HasKey(pg_Constant.UseAxisConstraints)) ? EditorPrefs.GetBool(pg_Constant.UseAxisConstraints) : USE_AXIS_CONSTRAINTS ); _BracketIncreaseValue = EditorPrefs.HasKey(pg_Constant.BracketIncreaseValue) ? EditorPrefs.GetFloat(pg_Constant.BracketIncreaseValue) : .25f; _GridUnits = (pg_Editor.SnapUnit)(EditorPrefs.HasKey(pg_Constant.GridUnit) ? EditorPrefs.GetInt(pg_Constant.GridUnit) : 0); return(true); }
public override float GetFloat(string key, float defaultValue = 0F) { return(EditorPrefs.GetFloat(key, defaultValue)); }
public FloatOption(string key, float defaultValue) : base(key) { value = EditorPrefs.GetFloat(prefix + key, defaultValue); }
public static float GetFloat(string settingPath, float defaultSetting) { return(EditorPrefs.GetFloat(settingPath + ".float", defaultSetting)); }
// 2Dから3Dに戻る際の位置を表示 void DrawBackLineList(ref List <Dimension.BackLine> backLines) { int lineCnt = 0, highCnt = 0; foreach (var line in backLines) { // 奥行き Vector3 depthCenter = stageForward * line.endDepth + Vector3.up * 3.0f; Handles.color = Color.blue; Vector3 depth = Handles.Slider(depthCenter, stageForward, 3.0f, Handles.ArrowCap, EditorPrefs.GetFloat("MoveSnapZ", 1f)); if (interacting) { backLines[lineCnt].endDepth = Conversion.Vector3ToFloat(Vector3.Scale(depth, stageForward)); } Vector3[] solidPoints = new Vector3[] { depth + Vector3.up * 3.0f + stageRight * 5.0f, depth + Vector3.up * 3.0f - stageRight * 5.0f, depth - Vector3.up * 3.0f - stageRight * 5.0f, depth - Vector3.up * 3.0f + stageRight * 5.0f }; Handles.color = Color.yellow; Handles.DrawSolidRectangleWithOutline(solidPoints, new Color(1, 1, 0, 0.3f), new Color(1, 1, 0, 1)); // 高さ if (lineCnt != 0) { highCnt = 0; Handles.color = Color.red; foreach (Vector2 highSide in line.highSide) { Handles.DrawLine( stageRight * highSide.x + Vector3.up * highSide.y + stageForward * backLines[lineCnt - 1].endDepth, stageRight * highSide.x + Vector3.up * highSide.y + stageForward * line.endDepth ); ++highCnt; } } ++lineCnt; } }
private void OnEnable() { Value = EditorPrefs.GetFloat("MyWizardTool.Value", Value); }
private static Vector3 DoPlanarHandle(PlaneHandle planeID, Vector3 handlePos, Quaternion rotation, float handleSize, float alpha) { int num = 0; int num2 = 0; switch (planeID) { case PlaneHandle.xyPlane: Handles.color = new Color(Handles.zAxisColor.r, Handles.zAxisColor.g, Handles.zAxisColor.b, alpha); num = 0; num2 = 1; break; case PlaneHandle.xzPlane: Handles.color = new Color(Handles.yAxisColor.r, Handles.yAxisColor.g, Handles.yAxisColor.b, alpha); num = 0; num2 = 2; break; case PlaneHandle.yzPlane: Handles.color = new Color(Handles.xAxisColor.r, Handles.xAxisColor.g, Handles.xAxisColor.b, alpha); num = 1; num2 = 2; break; } int index = 3 - num2 - num; Color color = Handles.color; Matrix4x4 matrix4x = Matrix4x4.TRS(handlePos, rotation, Vector3.one); Vector3 normalized; if (Camera.current.orthographic) { normalized = matrix4x.inverse.MultiplyVector(SceneView.currentDrawingSceneView.rotation * -Vector3.forward).normalized; } else { normalized = matrix4x.inverse.MultiplyPoint(SceneView.currentDrawingSceneView.camera.transform.position).normalized; } Vector3 result = handlePos; if (Mathf.Abs(normalized[index]) < 0.05f) { Handles.color = color; result = handlePos; } else { int id = GUIUtility.GetControlID(planeID.GetHashCode(), FocusType.Passive); Vector3 offset = Vector3.one; offset[num] = (normalized[num] >= -0.01f) ? 1 : -1; offset[num2] = (normalized[num2] >= -0.01f) ? 1 : -1; offset[index] = 0f; offset = rotation * (offset * handleSize * 0.5f); Vector3 slideDir1 = Vector3.zero; Vector3 slideDir2 = Vector3.zero; Vector3 handleDir = Vector3.zero; slideDir1[num] = 1f; slideDir2[num2] = 1f; handleDir[index] = 1f; slideDir1 = rotation * slideDir1; slideDir2 = rotation * slideDir2; handleDir = rotation * handleDir; Vector3[] verts = new Vector3[4] { handlePos + offset + (slideDir1 + slideDir2) * handleSize * 0.5f, handlePos + offset + (-slideDir1 + slideDir2) * handleSize * 0.5f, handlePos + offset + (-slideDir1 - slideDir2) * handleSize * 0.5f, handlePos + offset + (slideDir1 - slideDir2) * handleSize * 0.5f }; Vector3 snapSettings = new Vector3(EditorPrefs.GetFloat("MoveSnapX"), EditorPrefs.GetFloat("MoveSnapY"), EditorPrefs.GetFloat("MoveSnapZ")); Handles.DrawSolidRectangleWithOutline(verts, new Color(Handles.color.r, Handles.color.g, Handles.color.b, 0.1f), new Color(0f, 0f, 0f, 0f)); handlePos = Handles.Slider2D(id, handlePos, offset, handleDir, slideDir1, slideDir2, handleSize * 0.5f, Handles.RectangleHandleCap, new Vector2(snapSettings[num], snapSettings[num2])); Handles.color = color; result = handlePos; } return(result); }
void OnSceneGUI() { var proCamera2DRooms = (ProCamera2DRooms)target; if (proCamera2DRooms.ProCamera2D == null) { return; } // Text style for room numbers var guiStyle = new GUIStyle(); guiStyle.fontStyle = FontStyle.Bold; guiStyle.fontSize = 30; guiStyle.normal.textColor = EditorPrefsX.GetColor(PrefsData.RoomsColorKey, PrefsData.RoomsColorValue); guiStyle.alignment = TextAnchor.MiddleCenter; guiStyle.fixedWidth = 1f; guiStyle.fixedHeight = 1f; Handles.color = EditorPrefsX.GetColor(PrefsData.RoomsColorKey, PrefsData.RoomsColorValue); for (int i = 0; i < proCamera2DRooms.Rooms.Count; i++) { Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, 0f); // Button to toggle room editing var buttonSize = Mathf.Min(proCamera2DRooms.Rooms[i].Dimensions.width / 2f, proCamera2DRooms.Rooms[i].Dimensions.height / 2f); buttonSize = Mathf.Min(1, buttonSize); var buttonPosition = proCamera2DRooms.Rooms[i].Dimensions.position; if (proCamera2DRooms.UseRelativePosition) { buttonPosition.x += Vector3H(proCamera2DRooms.transform.position); buttonPosition.y += Vector3V(proCamera2DRooms.transform.position); } if (Handles.Button( buttonPosition, Quaternion.LookRotation(VectorHVD(0, 0, 1)), buttonSize, buttonSize, #if UNITY_5_5_OR_NEWER Handles.RectangleHandleCap)) #else Handles.RectangleCap)) #endif { if (i == _currentlyEditingRoom) { _currentlyEditingRoom = -1; } else { _currentlyEditingRoom = i; } } // Room number Handles.Label(VectorHV(buttonPosition.x, buttonPosition.y), i.ToString(), guiStyle); } // Room rect editor if (_currentlyEditingRoom != -1) { var currentDimensions = proCamera2DRooms.Rooms[_currentlyEditingRoom].Dimensions; // Snap value var snap = EditorPrefs.GetFloat("RoomsSnapping", PrefsData.RoomsSnapping); // Move var oldPos = VectorHV(currentDimensions.position.x, currentDimensions.position.y); if (proCamera2DRooms.UseRelativePosition) { oldPos.x += Vector3H(proCamera2DRooms.transform.position); oldPos.y += Vector3V(proCamera2DRooms.transform.position); } var newPos = Handles.PositionHandle(oldPos, Quaternion.identity); if (newPos != oldPos) { Undo.RecordObject(proCamera2DRooms, "MoveRoom"); currentDimensions.position = new Vector2(Vector3H(newPos), Vector3V(newPos)); if (proCamera2DRooms.UseRelativePosition) { currentDimensions.x -= Vector3H(proCamera2DRooms.transform.position); currentDimensions.y -= Vector3V(proCamera2DRooms.transform.position); } } // Draw rect editor var currentDimensionsRelative = currentDimensions; if (proCamera2DRooms.UseRelativePosition) { currentDimensionsRelative.x += Vector3H(proCamera2DRooms.transform.position); currentDimensionsRelative.y += Vector3V(proCamera2DRooms.transform.position); } var newDimensions = ResizeRect( currentDimensionsRelative, #if UNITY_5_5_OR_NEWER Handles.CubeHandleCap, #else Handles.CubeCap, #endif Color.green, Color.yellow, HandleUtility.GetHandleSize(Vector3.zero) * .1f, snap); // Undo if (newDimensions.x != currentDimensionsRelative.x || newDimensions.y != currentDimensionsRelative.y || newDimensions.width != currentDimensionsRelative.width || newDimensions.height != currentDimensionsRelative.height) { Undo.RecordObject(proCamera2DRooms, "ResizeRect"); } // Save new dimensions var newDimensionsRelative = newDimensions; if (proCamera2DRooms.UseRelativePosition) { newDimensionsRelative.x -= Vector3H(proCamera2DRooms.transform.position); newDimensionsRelative.y -= Vector3V(proCamera2DRooms.transform.position); } proCamera2DRooms.Rooms[_currentlyEditingRoom].Dimensions = newDimensionsRelative; // Redraw views if (Event.current.rawType == EventType.Used) { UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); } } }
private Vector3 SmallPositionHandle(Vector3 position, Quaternion rotation, float size, float alpha) { float handleSize = HandleUtility.GetHandleSize(position) * size; Color color = Handles.color; Color col; //X axis col = Handles.xAxisColor; col.a = alpha; Handles.color = col; GUI.SetNextControlName("xAxis"); position = Handles.Slider(position, rotation * Vector3.right, handleSize, Handles.ArrowHandleCap, EditorPrefs.GetFloat("MoveSnapX")); //Y axis col = Handles.yAxisColor; col.a = alpha; Handles.color = col; GUI.SetNextControlName("yAxis"); position = Handles.Slider(position, rotation * Vector3.up, handleSize, Handles.ArrowHandleCap, EditorPrefs.GetFloat("MoveSnapY")); //Z axis col = Handles.zAxisColor; col.a = alpha; Handles.color = col; GUI.SetNextControlName("zAxis"); position = Handles.Slider(position, rotation * Vector3.forward, handleSize, Handles.ArrowHandleCap, EditorPrefs.GetFloat("MoveSnapZ")); //Handles.Slider2D() /* * if (Handles.free) { * Handles.color = Handles.centerColor; * GUI.SetNextControlName("FreeMoveAxis"); * Vector3 arg_1CF_0 = position; * float arg_1CF_2 = handleSize * 0.15f; * Vector3 arg_1CF_3 = SnapSettings.move; * if (Handles.<> f__mg$cache5 == null) * { * Handles.<> f__mg$cache5 = new Handles.CapFunction(Handles.RectangleHandleCap); * } * position = Handles.FreeMoveHandle(arg_1CF_0, rotation, arg_1CF_2, arg_1CF_3, Handles.<> f__mg$cache5); * }*/ position = DoPlanarHandle(PlaneHandle.xyPlane, position, rotation, HandleUtility.GetHandleSize(position) * 0.2f, alpha); position = DoPlanarHandle(PlaneHandle.xzPlane, position, rotation, HandleUtility.GetHandleSize(position) * 0.2f, alpha); position = DoPlanarHandle(PlaneHandle.yzPlane, position, rotation, HandleUtility.GetHandleSize(position) * 0.2f, alpha); Handles.color = color; return(position); }
private void OnSceneGUI() { if (!Ferr2DT_PathTerrain.showGUI) { return; } Ferr2D_Path path = (Ferr2D_Path)target; Ferr2DT_PathTerrain terrain = path.GetComponent <Ferr2DT_PathTerrain>(); GUIStyle iconStyle = new GUIStyle(); iconStyle.alignment = TextAnchor.MiddleCenter; snap = new Vector3(EditorPrefs.GetFloat("MoveSnapX", 1), EditorPrefs.GetFloat("MoveSnapY", 1), EditorPrefs.GetFloat("MoveSnapZ", 1)); // setup undoing things Undo.RecordObject(target, "Modified Path"); if (Event.current.type == EventType.repaint && terrain != null) { Ferr2DT_PathTerrainEditor.DrawColliderEdge(terrain); } // draw the path line if (Event.current.type == EventType.repaint) { DoPath(path); } // Check for drag-selecting multiple points DragSelect(path); // do adding verts in when the shift key is down! if (Event.current.shift && !Event.current.control) { DoShiftAdd(path, iconStyle); } // draw and interact with all the path handles DoHandles(path, iconStyle); // if this was an undo, refresh stuff too if (Event.current.type == EventType.ValidateCommand) { switch (Event.current.commandName) { case "UndoRedoPerformed": // Only rebuild this from an undo if the inspector is not visible. UnityEngine.Object[] objs = Resources.FindObjectsOfTypeAll(Type.GetType("UnityEditor.InspectorWindow, UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", true)); if (objs == null || objs.Length == 0) { path.UpdateDependants(true); if (OnChanged != null) { OnChanged(); } } break; } } // update everything that relies on this path, if the GUI changed if (GUI.changed) { if (PrefabUtility.GetPrefabParent(target) != null) { NudgeArray(pathVerts); serializedObject.ApplyModifiedProperties(); } UpdateDependentsSmart(path, false, false); EditorUtility.SetDirty(target); prevChanged = true; } else if (Event.current.type == EventType.used) { if (prevChanged == true) { UpdateDependentsSmart(path, false, true); } prevChanged = false; } }
protected void OnGUI() { GUILayout.BeginVertical(); GUILayout.Space((float)SPSettings.padding.top); GUILayout.BeginHorizontal(); GUILayout.Space((float)SPSettings.padding.left); GUILayout.BeginVertical(); GUILayout.Label("General", EditorStyles.boldLabel); GUILayout.BeginVertical(GUI.skin.box); GUILayout.Space(6f); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUI.changed = false; bool drwe = GUILayout.Toggle(EditorPrefs.GetBool(SPTools.Settings_DisableReadWriteEnabled), " Disable Read/Write Enabled of the source textures after packing ?"); if (GUI.changed) { EditorPrefs.SetBool(SPTools.Settings_DisableReadWriteEnabled, drwe); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUI.changed = false; bool amsos = GUILayout.Toggle(EditorPrefs.GetBool(SPTools.Settings_AllowMuliSpritesOneSource), " Allow multiple sprites from the same source ?"); if (GUI.changed) { EditorPrefs.SetBool(SPTools.Settings_AllowMuliSpritesOneSource, amsos); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.EndVertical(); GUILayout.Label("Layout", EditorStyles.boldLabel); GUILayout.BeginVertical(GUI.skin.box); GUILayout.Space(6f); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUI.changed = false; bool ust = GUILayout.Toggle(EditorPrefs.GetBool(SPTools.Settings_UseSpriteThumbsKey), " Use sprite thumbs ?"); if (GUI.changed) { EditorPrefs.SetBool(SPTools.Settings_UseSpriteThumbsKey, ust); this.InvokeRepaint(); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label("Thumbs Max Height: " + EditorPrefs.GetFloat(SPTools.Settings_ThumbsHeightKey).ToString(), GUILayout.Width(150f)); GUI.changed = false; float th = GUILayout.HorizontalSlider(EditorPrefs.GetFloat(SPTools.Settings_ThumbsHeightKey), 20f, 200f, GUILayout.ExpandWidth(true)); if (GUI.changed) { EditorPrefs.SetFloat(SPTools.Settings_ThumbsHeightKey, Mathf.Round(th)); this.InvokeRepaint(); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUI.changed = false; bool ssv = GUILayout.Toggle(EditorPrefs.GetBool(SPTools.Settings_UseScrollViewKey), " Use scroll view for sprites ?"); if (GUI.changed) { EditorPrefs.SetBool(SPTools.Settings_UseScrollViewKey, ssv); this.InvokeRepaint(); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label( "Scroll View Height: " + EditorPrefs.GetFloat(SPTools.Settings_ScrollViewHeightKey).ToString(), GUILayout.Width(150f)); GUI.changed = false; float svs = GUILayout.HorizontalSlider(EditorPrefs.GetFloat(SPTools.Settings_ScrollViewHeightKey), 40f, 500f, GUILayout.ExpandWidth(true)); if (GUI.changed) { EditorPrefs.SetFloat(SPTools.Settings_ScrollViewHeightKey, Mathf.Round(svs)); this.InvokeRepaint(); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.EndVertical(); GUILayout.EndVertical(); GUILayout.Space((float)SPSettings.padding.right); GUILayout.EndHorizontal(); GUILayout.Space((float)SPSettings.padding.bottom); GUILayout.EndVertical(); }
public static void Load() { SpineHandles.handleScale = EditorPrefs.GetFloat(SCENE_ICONS_SCALE_KEY, DEFAULT_SCENE_ICONS_SCALE); GetOrCreateSettings(); }
private void DoHandles(Ferr2D_Path path, GUIStyle iconStyle) { Vector3 snap = Event.current.control ? new Vector3(EditorPrefs.GetFloat("MoveSnapX"), EditorPrefs.GetFloat("MoveSnapY"), EditorPrefs.GetFloat("MoveSnapZ")) : Vector3.zero; Transform transform = path.transform; Matrix4x4 mat = transform.localToWorldMatrix; Matrix4x4 invMat = transform.worldToLocalMatrix; Transform camTransform = SceneView.lastActiveSceneView.camera.transform; Ferr2DT_PathTerrain terrain = path.GetComponent <Ferr2DT_PathTerrain>(); if (terrain) { terrain.MatchOverrides(); } Handles.color = new Color(1, 1, 1, 1); for (int i = 0; i < path.pathVerts.Count; i++) { Vector3 pos = mat.MultiplyPoint3x4(path.pathVerts[i]); Vector3 posStart = pos; bool isSelected = false; if (selectedPoints != null) { isSelected = selectedPoints.Contains(i); } // check if we want to remove points if (Event.current.alt) { float handleScale = HandleScale(posStart); Handles.DrawCapFunction cap = (isSelected || selectedPoints.Count <= 0) ? (Handles.DrawCapFunction)CapDotMinusSelected : (Handles.DrawCapFunction)CapDotMinus; if (Handles.Button(posStart, camTransform.rotation, handleScale, handleScale, cap)) { if (!isSelected) { selectedPoints.Clear(); selectedPoints.Add(i); } for (int s = 0; s < selectedPoints.Count; s++) { if (terrain) { terrain.RemovePoint(selectedPoints[s]); } else { path.pathVerts.RemoveAt(selectedPoints[s]); } if (selectedPoints[s] <= i) { i--; } for (int u = 0; u < selectedPoints.Count; u++) { if (selectedPoints[u] > selectedPoints[s]) { selectedPoints[u] -= 1; } } } selectedPoints.Clear(); GUI.changed = true; } else if (Ferr2DT_SceneOverlay.editMode != Ferr2DT_EditMode.None) { if (terrain && i + 1 < path.pathVerts.Count) { float scale = handleScale * 0.5f; Vector3 dirOff = GetTickerOffset(path, pos, i); Vector3 posDirOff = posStart + dirOff; if (IsVisible(posDirOff)) { cap = null; if (Ferr2DT_SceneOverlay.editMode == Ferr2DT_EditMode.Override) { cap = GetDirIcon(terrain.directionOverrides[i]); } else if (Ferr2DT_SceneOverlay.editMode == Ferr2DT_EditMode.Scale) { cap = CapDotScale; } if (Event.current.alt) { cap = CapDotReset; } if (Handles.Button(posDirOff, camTransform.rotation, scale, scale, cap)) { if (selectedPoints.Count < 2 || isSelected == false) { selectedPoints.Clear(); selectedPoints.Add(i); isSelected = true; } for (int s = 0; s < selectedPoints.Count; s++) { if (Ferr2DT_SceneOverlay.editMode == Ferr2DT_EditMode.Override) { terrain.directionOverrides[selectedPoints[s]] = Ferr2DT_TerrainDirection.None; } else if (Ferr2DT_SceneOverlay.editMode == Ferr2DT_EditMode.Scale) { terrain.vertScales [selectedPoints[s]] = 1; } } GUI.changed = true; } } } } } else { // check for moving the point Handles.DrawCapFunction cap = CapDot; if (Event.current.control) { cap = isSelected ? (Handles.DrawCapFunction)CapDotSelectedSnap : (Handles.DrawCapFunction)CapDotSnap; } else { cap = isSelected ? (Handles.DrawCapFunction)CapDotSelected : (Handles.DrawCapFunction)CapDot; } Vector3 result = Handles.FreeMoveHandle( posStart, camTransform.rotation, HandleScale(pos), snap, cap); if (result != posStart) { if (selectedPoints.Count < 2 || isSelected == false) { selectedPoints.Clear(); selectedPoints.Add(i); isSelected = true; } if (!(Event.current.control && Ferr2DT_Menu.SnapMode == Ferr2DT_Menu.SnapType.SnapRelative)) { result = GetRealPoint(result, transform); } Vector3 global = result; if (Event.current.control && Ferr2DT_Menu.SnapMode == Ferr2DT_Menu.SnapType.SnapGlobal) { global = SnapVector(global, snap); } Vector3 local = invMat.MultiplyPoint3x4(global); if (Event.current.control && Ferr2DT_Menu.SnapMode == Ferr2DT_Menu.SnapType.SnapLocal) { local = SnapVector(local, snap); } if (!Event.current.control && Ferr2DT_SceneOverlay.smartSnap) { local = SmartSnap(local, path.pathVerts, selectedPoints, Ferr2DT_Menu.SmartSnapDist); } Vector2 relative = new Vector2(local.x, local.y) - path.pathVerts[i]; for (int s = 0; s < selectedPoints.Count; s++) { path.pathVerts[selectedPoints[s]] += relative; } } // if using terrain, check to see for any edge overrides if (Ferr2DT_SceneOverlay.showIndices) { Vector3 labelPos = posStart + (Vector3)Ferr2D_Path.GetNormal(path.pathVerts, i, path.closed); Handles.color = Color.white; Handles.Label(labelPos, "" + i); Handles.color = new Color(1, 1, 1, 0); } if (terrain) { float scale = HandleScale(pos) * 0.5f; Vector3 dirOff = GetTickerOffset(path, pos, i); Vector3 posDirOff = posStart + dirOff; if (Ferr2DT_SceneOverlay.editMode == Ferr2DT_EditMode.Override && i + 1 < path.pathVerts.Count) { if (IsVisible(posDirOff) && terrain.directionOverrides != null) { cap = Event.current.alt ? (Handles.DrawCapFunction)CapDotReset : GetDirIcon(terrain.directionOverrides[i]); if (Handles.Button(posDirOff, camTransform.rotation, scale, scale, cap)) { if (selectedPoints.Count < 2 || isSelected == false) { selectedPoints.Clear(); selectedPoints.Add(i); isSelected = true; } Ferr2DT_TerrainDirection dir = NextDir(terrain.directionOverrides[i]); for (int s = 0; s < selectedPoints.Count; s++) { terrain.directionOverrides[selectedPoints[s]] = dir; } GUI.changed = true; } } } else if (Ferr2DT_SceneOverlay.editMode == Ferr2DT_EditMode.Scale) { if (IsVisible(posDirOff)) { cap = Event.current.alt ? (Handles.DrawCapFunction)CapDotReset : (Handles.DrawCapFunction)CapDotScale; Vector3 scaleMove = Handles.FreeMoveHandle(posDirOff, camTransform.rotation, scale, Vector3.zero, cap); float scaleAmt = scaleMove.y - posDirOff.y; if (Mathf.Abs(scaleAmt) > 0.01f) { if (selectedPoints.Count < 2 || isSelected == false) { selectedPoints.Clear(); selectedPoints.Add(i); isSelected = true; } float vertScale = terrain.vertScales[i] - Event.current.delta.y / 100f; vertScale = Mathf.Clamp(vertScale, 0.2f, 3f); for (int s = 0; s < selectedPoints.Count; s++) { terrain.vertScales[selectedPoints[s]] = vertScale; } GUI.changed = true; } } } } // make sure we can add new point at the midpoints! if (i + 1 < path.pathVerts.Count || path.closed == true) { int index = path.closed && i + 1 == path.pathVerts.Count ? 0 : i + 1; Vector3 pos2 = mat.MultiplyPoint3x4(path.pathVerts[index]); Vector3 mid = (pos + pos2) / 2; float handleScale = HandleScale(mid); if (Handles.Button(mid, camTransform.rotation, handleScale, handleScale, CapDotPlus)) { Vector2 pt = invMat.MultiplyPoint3x4(mid); if (terrain) { terrain.AddPoint(pt, index); } else { path.pathVerts.Insert(index, pt); } } } } } if (Event.current.type == EventType.keyDown && Event.current.keyCode == KeyCode.Delete && selectedPoints.Count > 0) { for (int s = 0; s < selectedPoints.Count; s++) { if (terrain) { terrain.RemovePoint(selectedPoints[s]); } else { path.pathVerts.RemoveAt(selectedPoints[s]); } for (int u = 0; u < selectedPoints.Count; u++) { if (selectedPoints[u] > selectedPoints[s]) { selectedPoints[u] -= 1; } } } selectedPoints.Clear(); GUI.changed = true; Event.current.Use(); } }
public static void Align() { // Just get the objects in the selection that are editable GameObjects var relevantObjects = Selection.GetFiltered <GameObject>(SelectionMode.Editable); // If none are selected, then nothing happens if (relevantObjects.Length == 0) { return; } // The individual snap values have to be pulled // out of the editor preferences like so var snapX = EditorPrefs.GetFloat("MoveSnapX"); var snapY = EditorPrefs.GetFloat("MoveSnapY"); var snapZ = EditorPrefs.GetFloat("MoveSnapZ"); // Snapping cannot occur on an axis whose value is 0. // If all three axes have zero values, then nothing happens if (snapX == 0 && snapY == 0 && snapZ == 0) { Debug.LogWarning("All three snap distances are 0, so no snapping was performed"); return; } // James said I should do this Undo.IncrementCurrentGroup(); // Create a name for the undo group (what shows up in the Edit menu) Undo.SetCurrentGroupName("Align Selected to Grid"); // For each object to be snapped... foreach (var obj in relevantObjects) { var pos = obj.transform.position; // On each axis, if snapping can occur, perform the snap algorithm if (snapX != 0) { pos.x /= snapX; pos.x = Mathf.Round(pos.x); pos.x *= snapX; } if (snapY != 0) { pos.y /= snapY; pos.y = Mathf.Round(pos.y); pos.y *= snapY; } if (snapZ != 0) { pos.z /= snapZ; pos.z = Mathf.Round(pos.z); pos.z *= snapZ; } // Record the state of the object's transform (not the object // itself -- thanks again to James), and then modify its position Undo.RecordObject(obj.transform, "Align Object to Grid"); obj.transform.position = pos; } // Collapse the current Undo group so that // it can all be undone / redone at once Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); }
private void DoShiftAdd(Ferr2D_Path path, GUIStyle iconStyle) { Vector3 snap = Event.current.control ? new Vector3(EditorPrefs.GetFloat("MoveSnapX"), EditorPrefs.GetFloat("MoveSnapY"), EditorPrefs.GetFloat("MoveSnapZ")) : Vector3.zero; Ferr2DT_PathTerrain terrain = path.gameObject.GetComponent <Ferr2DT_PathTerrain>(); Transform transform = path.transform; Transform camTransform = SceneView.lastActiveSceneView.camera.transform; Vector3 pos = transform.InverseTransformPoint(GetMousePos(Event.current.mousePosition, transform)); bool hasDummy = path.pathVerts.Count <= 0; if (hasDummy) { path.pathVerts.Add(Vector2.zero); } int closestID = path.GetClosestSeg(pos); int secondID = closestID + 1 >= path.Count ? 0 : closestID + 1; float firstDist = Vector2.Distance(pos, path.pathVerts[closestID]); float secondDist = Vector2.Distance(pos, path.pathVerts[secondID]); Vector3 local = pos; if (Event.current.control && Ferr2DT_Menu.SnapMode == Ferr2DT_Menu.SnapType.SnapLocal) { local = SnapVector(local, snap); } Vector3 global = transform.TransformPoint(pos); if (Event.current.control && Ferr2DT_Menu.SnapMode == Ferr2DT_Menu.SnapType.SnapGlobal) { global = SnapVector(global, snap); } Handles.color = Color.white; if (!(secondID == 0 && !path.closed && firstDist > secondDist)) { Handles.DrawLine(global, transform.TransformPoint(path.pathVerts[closestID])); } if (!(secondID == 0 && !path.closed && firstDist < secondDist)) { Handles.DrawLine(global, transform.TransformPoint(path.pathVerts[secondID])); } Handles.color = new Color(1, 1, 1, 1); Vector3 handlePos = transform.TransformPoint(pos); float scale = HandleScale(handlePos); if (Handles.Button(handlePos, camTransform.rotation, scale, scale, CapDotPlus)) { Vector3 finalPos = transform.InverseTransformPoint(global); if (secondID == 0) { if (firstDist < secondDist) { if (terrain) { terrain.AddPoint(finalPos); } else { path.pathVerts.Add(finalPos); } } else { if (terrain) { terrain.AddPoint(finalPos, 0); } else { path.pathVerts.Insert(0, finalPos); } } } else { if (terrain) { terrain.AddPoint(finalPos, Mathf.Max(closestID, secondID)); } else { path.pathVerts.Insert(Mathf.Max(closestID, secondID), finalPos); } } selectedPoints.Clear(); GUI.changed = true; } if (hasDummy) { path.pathVerts.RemoveAt(0); } }
public override void OnInspectorGUI() { Transform t = (Transform)target; // Replicate the standard transform inspector gui EditorGUI.indentLevel = 0; Vector3 position = EditorGUILayout.Vector3Field("Position", t.localPosition); Vector3 eulerAngles = EditorGUILayout.Vector3Field("Rotation", t.localEulerAngles); Vector3 scale = EditorGUILayout.Vector3Field("Scale", t.localScale); // if (GUILayout.Button((showTools) ? "Hide Transform Tools" : "Show Transform Tools")) { showTools = !showTools; EditorPrefs.SetBool("ShowTools", showTools); } // START TRANSFORM TOOLS FOLD DOWN // if (showTools) { if (!copyPosition && !copyRotation && !copyScale) { selectionNullError = true; } else { selectionNullError = false; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(selectionNullError ? "Nothing Selected" : "Copy Transform")) { if (copyPosition) { EditorPrefs.SetFloat("LocalPosX", t.localPosition.x); EditorPrefs.SetFloat("LocalPosY", t.localPosition.y); EditorPrefs.SetFloat("LocalPosZ", t.localPosition.z); } if (copyRotation) { EditorPrefs.SetFloat("LocalRotX", t.localEulerAngles.x); EditorPrefs.SetFloat("LocalRotY", t.localEulerAngles.y); EditorPrefs.SetFloat("LocalRotZ", t.localEulerAngles.z); } if (copyScale) { EditorPrefs.SetFloat("LocalScaleX", t.localScale.x); EditorPrefs.SetFloat("LocalScaleY", t.localScale.y); EditorPrefs.SetFloat("LocalScaleZ", t.localScale.z); } Debug.Log("LP: " + t.localPosition + " LT: (" + t.localEulerAngles.x + ", " + t.localEulerAngles.y + ", " + t.localEulerAngles.z + ") LS: " + t.localScale); } if (GUILayout.Button("Paste Transform")) { Vector3 tV3 = new Vector3(); if (pastePosition) { tV3.x = EditorPrefs.GetFloat("LocalPosX", 0.0f); tV3.y = EditorPrefs.GetFloat("LocalPosY", 0.0f); tV3.z = EditorPrefs.GetFloat("LocalPosZ", 0.0f); t.localPosition = tV3; } if (pasteRotation) { tV3.x = EditorPrefs.GetFloat("LocalRotX", 0.0f); tV3.y = EditorPrefs.GetFloat("LocalRotY", 0.0f); tV3.z = EditorPrefs.GetFloat("LocalRotZ", 0.0f); t.localEulerAngles = tV3; } if (pasteScale) { tV3.x = EditorPrefs.GetFloat("LocalScaleX", 1.0f); tV3.y = EditorPrefs.GetFloat("LocalScaleY", 1.0f); tV3.z = EditorPrefs.GetFloat("LocalScaleZ", 1.0f); t.localScale = tV3; } Debug.Log("LP: " + t.localPosition + " LT: " + t.localEulerAngles + " LS: " + t.localScale); } EditorGUILayout.EndHorizontal(); EditorGUIUtility.LookLikeControls(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Position", GUILayout.Width(75)); GUILayout.Label("Rotation", GUILayout.Width(75)); GUILayout.Label("Scale", GUILayout.Width(50)); if (GUILayout.Button("All", GUILayout.MaxWidth(40))) { TransformCopyAll(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); copyPosition = EditorGUILayout.Toggle(copyPosition, GUILayout.Width(75)); copyRotation = EditorGUILayout.Toggle(copyRotation, GUILayout.Width(65)); copyScale = EditorGUILayout.Toggle(copyScale, GUILayout.Width(45)); if (GUILayout.Button("None", GUILayout.MaxWidth(40))) { TransformCopyNone(); } EditorGUILayout.EndHorizontal(); EditorGUIUtility.LookLikeInspector(); } // END TRANSFORM TOOLS FOLD DOWN // if (GUI.changed) { SetCopyPasteBools(); Undo.RegisterUndo(t, "Transform Change"); t.localPosition = FixIfNaN(position); t.localEulerAngles = FixIfNaN(eulerAngles); t.localScale = FixIfNaN(scale); } }
public static void Reload() { RealtimeCSG.CSGSettings.LockAxisX = EditorPrefs.GetBool("LockAxisX", false); RealtimeCSG.CSGSettings.LockAxisY = EditorPrefs.GetBool("LockAxisY", false); RealtimeCSG.CSGSettings.LockAxisZ = EditorPrefs.GetBool("LockAxisZ", false); RealtimeCSG.CSGSettings.UniformGrid = EditorPrefs.GetBool("UniformGrid", true); RealtimeCSG.CSGSettings.EditMode = (ToolEditMode)EditorPrefs.GetInt("EditMode", (int)ToolEditMode.Generate); var moveSnapVector = new Vector3(EditorPrefs.GetFloat("MoveSnapX", 1.0f), EditorPrefs.GetFloat("MoveSnapY", 1.0f), EditorPrefs.GetFloat("MoveSnapZ", 1.0f)); RealtimeCSG.CSGSettings.SnapVector = moveSnapVector; var moveOffsetVector = new Vector3(EditorPrefs.GetFloat("DefaultMoveOffsetX", 0.0f), EditorPrefs.GetFloat("DefaultMoveOffsetY", 0.0f), EditorPrefs.GetFloat("DefaultMoveOffsetZ", 0.0f)); RealtimeCSG.CSGSettings.DefaultMoveOffset = moveOffsetVector; var rotateOffsetVector = new Vector3(EditorPrefs.GetFloat("DefaultRotateOffsetX", 0.0f), EditorPrefs.GetFloat("DefaultRotateOffsetY", 0.0f), EditorPrefs.GetFloat("DefaultRotateOffsetZ", 0.0f)); RealtimeCSG.CSGSettings.DefaultRotateOffset = rotateOffsetVector; RealtimeCSG.CSGSettings.ShapeBuildMode = (ShapeMode)EditorPrefs.GetInt("ShapeBuildMode", (int)ShapeMode.Box); RealtimeCSG.CSGSettings.GridVisible = EditorPrefs.GetBool("ShowGrid", true); RealtimeCSG.CSGSettings.SnapToGrid = EditorPrefs.GetBool("ForceSnapToGrid", true); var helperSurfaces = (HelperSurfaceFlags)EditorPrefs.GetInt("HelperSurfaces", (int)DefaultHelperSurfaceFlags); RealtimeCSG.CSGSettings.VisibleHelperSurfaces = helperSurfaces; RealtimeCSG.CSGSettings.ClipMode = (ClipMode)EditorPrefs.GetInt("ClipMode", 0); RealtimeCSG.CSGSettings.EnableRealtimeCSG = EditorPrefs.GetBool("EnableRealtimeCSG", true); var defaultMaterialGUID = EditorPrefs.GetString("DefaultMaterial", null); if (defaultMaterialGUID != null) { var defaultMaterialAssetPath = AssetDatabase.GUIDToAssetPath(defaultMaterialGUID); var materialFromID = AssetDatabase.LoadAssetAtPath <Material>(defaultMaterialAssetPath); if (materialFromID) { DefaultMaterial = materialFromID; } else { DefaultMaterial = MaterialUtility.WallMaterial; } } else { DefaultMaterial = MaterialUtility.WallMaterial; } RealtimeCSG.CSGSettings.SnapScale = EditorPrefs.GetFloat("ScaleSnap", 0.1f); RealtimeCSG.CSGSettings.SnapRotation = EditorPrefs.GetFloat("RotationSnap", 15.0f); RealtimeCSG.CSGSettings.DefaultShapeHeight = EditorPrefs.GetFloat("DefaultShapeHeight", 1.0f); RealtimeCSG.CSGSettings.CurveSides = (uint)EditorPrefs.GetInt("CurveSides", 10); CircleSides = Mathf.Max(3, EditorPrefs.GetInt("CircleSides", 18)); CircleOffset = EditorPrefs.GetFloat("CircleOffset", 0); CircleSmoothShading = EditorPrefs.GetBool("CircleSmoothShading", true); CircleSingleSurfaceEnds = EditorPrefs.GetBool("CircleSingleSurfaceEnds", true); CircleDistanceToSide = EditorPrefs.GetBool("CircleDistanceToSide", true); CircleRecenter = EditorPrefs.GetBool("CircleRecenter", true); SphereSplits = Mathf.Max(1, EditorPrefs.GetInt("SphereSplits", 1)); SphereOffset = EditorPrefs.GetFloat("SphereOffset", 0); SphereSmoothShading = EditorPrefs.GetBool("SphereSmoothShading", true); SphereDistanceToSide = EditorPrefs.GetBool("SphereDistanceToSide", true); HemiSphereMode = EditorPrefs.GetBool("HemiSphereMode", false); LinearStairsStepLength = EditorPrefs.GetFloat("LinearStairsStepLength", 0.30f); LinearStairsStepHeight = EditorPrefs.GetFloat("LinearStairsStepHeight", 0.20f); LinearStairsStepWidth = EditorPrefs.GetFloat("LinearStairsStepWidth", 1.0f); LinearStairsTotalSteps = EditorPrefs.GetInt("LinearStairsTotalSteps", 4); LinearStairsLength = EditorPrefs.GetFloat("LinearStairsLength", 16.0f); LinearStairsHeight = EditorPrefs.GetFloat("LinearStairsHeight", 16.0f); LinearStairsLengthOffset = EditorPrefs.GetFloat("LinearStairsLengthOffset", 0.0f); LinearStairsHeightOffset = EditorPrefs.GetFloat("LinearStairsHeightOffset", 0.0f); var distanceUnit = (DistanceUnit)EditorPrefs.GetInt("DistanceUnit", (int)DistanceUnit.Meters); RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit; var sceneViews = SortedSceneViews(); EnsureValidSceneviewNames(sceneViews); var arrayString = EditorPrefs.GetString("Wireframe", string.Empty); if (arrayString.Contains(',')) { LegacyLoadWireframeSettings(sceneViews, arrayString); } else { LoadWireframeSettings(sceneViews, arrayString); } UpdateSnapSettings(); }
public Gap(Type toolType) : base(toolType) { value = EditorPrefs.GetFloat($"[Prefabshop] {toolType.Name}.{this.GetType().Name}", value); }
private void LoadSettings() { m_PinchAmount = EditorPrefs.GetFloat("Unity.TerrainTools.Pinch.PinchAmount", 5.0f); m_AffectHeight = EditorPrefs.GetBool("Unity.TerrainTools.Pinch.Heightmap", true); m_AffectMaterials = EditorPrefs.GetBool("Unity.TerrainTools.Pinch.Materials", true); }
public static void ReloadSnapSettings() { xSnap = EditorPrefs.GetFloat("MoveSnapX", 1f); ySnap = EditorPrefs.GetFloat("MoveSnapY", 1f); zSnap = EditorPrefs.GetFloat("MoveSnapZ", 1f); }
// Start is called before the first frame update void Start() { Time.timeScale = 1; #if UNITY_EDITOR DebugNotificationGenerator.Notify("Qキーでデバッグ表示ON/OFF"); #else DebugNotificationGenerator.Notify("4本マルチタッチでデバッグ表示ON/OFF"); #endif #if UNITY_EDITOR isTestPlay = EditorPrefs.GetBool("testPlayFlag", false); if (isTestPlay) { Debug.Log("これはテストプレイです😀"); EditorPrefs.SetBool("testPlayFlag", false); mode = PlayMode.Debug; var path = "Assets/Main/Games/TestPlayPackage.asset"; singleGame = AssetDatabase.LoadAssetAtPath <GamePackage>(path); Time.timeScale = EditorPrefs.GetFloat("timeScale", 1); //Initialization(); } #endif //Debug.Log(SceneManager.GetActiveScene().buildIndex); /* * if (mode != PlayMode.None) * { * Initialization(); * } */ //やばい実装、後で直す if (SceneManager.GetActiveScene().buildIndex == 1) { mode = PlayMode.Normal; } else { //IsGamePlaying = true; //mode = PlayMode.None; } if (mode != PlayMode.None) { Initialization(); } statementMesh.gameObject.SetActive(false); //デバッグ用 //EndGame(); DebugTextManager.Display(() => "TimeScale:" + Time.timeScale + "\n"); //DebugTextManager.Display(() => "progress:" + async.progress + "\n"); //DebugTextManager.Display(() => "IsGamePlaying:" + IsGamePlaying.ToString() + "\n"); DebugTextManager.Display(() => "mode:" + mode.ToString() + "\n"); //DebugTextManager.Display(() => "gameType:" + currentGameType.ToString() + "\n"); //DebugTextManager.Display(() => "Loading:" + (async.progress * 100).ToString("D3") + "%\n"); //DebugTextManager.Display(() => "Aspect:" + managerCamera.aspect + "\n"); //DebugTextManager.Display(() => "AdsIsReady:" + Advertisement.IsReady() + "\n"); //managerCammera.DOAspect(1, 5); //managerCammera.aspect = 16f / 9f; //カメラをアス比に合わせる設定 //managerCamera.orthographicSize *= 16f / 9f / managerCamera.aspect; }
/// <summary> /// Get the previously saved float value. /// </summary> static public float GetFloat(string name, float defaultValue) { return(EditorPrefs.GetFloat(name, defaultValue)); }
public override void Init() { this.enabled = EditorPrefs.GetBool(FormKey("enabled"), true); this.focus = EditorPrefs.GetBool(FormKey("focus"), true); this.disableAlpa = EditorPrefs.GetFloat(FormKey("disableAlpa"), this.disableAlpa); }
void Load() { //Debug.Log("Loading..."); //Booleans if (EditorPrefs.HasKey("textDebugging")) { textDebugging = EditorPrefs.GetBool("textDebugging"); } if (EditorPrefs.HasKey("objectDebugging")) { objectDebugging = EditorPrefs.GetBool("objectDebugging"); } if (EditorPrefs.HasKey("debugLineBackground")) { debugLineBackground = EditorPrefs.GetBool("debugLineBackground"); } if (EditorPrefs.HasKey("debugObjectBackground")) { debugObjectBackground = EditorPrefs.GetBool("debugObjectBackground"); } if (EditorPrefs.HasKey("scaleWithDistance")) { scaleWithDistance = EditorPrefs.GetBool("scaleWithDistance"); } if (EditorPrefs.HasKey("drawGraph")) { drawGraph = EditorPrefs.GetBool("drawGraph"); } //Integers if (EditorPrefs.HasKey("drawShapeType")) { drawType = EditorPrefs.GetInt("drawShapeType"); } if (EditorPrefs.HasKey("debugLineTextSize")) { debugLineTextSize = EditorPrefs.GetInt("debugLineTextSize"); } if (EditorPrefs.HasKey("debugObjectTextSize")) { debugObjectTextSize = EditorPrefs.GetInt("debugObjectTextSize"); } //Floats if (EditorPrefs.HasKey("debugWindowWidth")) { debugWindowWidth = EditorPrefs.GetFloat("debugWindowWidth"); } if (EditorPrefs.HasKey("debugWindowHeight")) { debugWindowHeight = EditorPrefs.GetFloat("debugWindowHeight"); } if (EditorPrefs.HasKey("graphUpdateTime")) { graphUpdateTime = EditorPrefs.GetFloat("graphUpdateTime"); } //Colors if (EditorPrefs.HasKey("shapeColorR")) { defaultColor = new Color(EditorPrefs.GetFloat("shapeColorR"), EditorPrefs.GetFloat("shapeColorG"), EditorPrefs.GetFloat("shapeColorB"), 1); } if (EditorPrefs.HasKey("debugLineColorR")) { debugLineColor = new Color(EditorPrefs.GetFloat("debugLineColorR"), EditorPrefs.GetFloat("debugLineColorG"), EditorPrefs.GetFloat("debugLineColorB"), 1); } if (EditorPrefs.HasKey("debugObjectColorR")) { debugObjectColor = new Color(EditorPrefs.GetFloat("debugObjectColorR"), EditorPrefs.GetFloat("debugObjectColorG"), EditorPrefs.GetFloat("debugObjectColorB"), 1); } //Rects if (EditorPrefs.HasKey("graphRectX")) { graphRect = new Rect(EditorPrefs.GetInt("graphRectX"), EditorPrefs.GetInt("graphRectY"), EditorPrefs.GetInt("graphRectW"), EditorPrefs.GetInt("graphRectH")); } //Debug.Log("Loaded!"); }
public static bool LoadPreferences() { s_GridColorX = (EditorPrefs.HasKey(PreferenceKeys.GridColorX)) ? EditorUtility.ColorWithString(EditorPrefs.GetString(PreferenceKeys.GridColorX)) : Defaults.GridColorX; s_GridColorY = (EditorPrefs.HasKey(PreferenceKeys.GridColorY)) ? EditorUtility.ColorWithString(EditorPrefs.GetString(PreferenceKeys.GridColorY)) : Defaults.GridColorY; s_GridColorZ = (EditorPrefs.HasKey(PreferenceKeys.GridColorZ)) ? EditorUtility.ColorWithString(EditorPrefs.GetString(PreferenceKeys.GridColorZ)) : Defaults.GridColorZ; s_AlphaBump = EditorPrefs.GetFloat(PreferenceKeys.AlphaBump, Defaults.AlphaBump); s_BracketIncreaseValue = EditorPrefs.HasKey(PreferenceKeys.BracketIncreaseValue) ? EditorPrefs.GetFloat(PreferenceKeys.BracketIncreaseValue) : .25f; s_GridUnits = (SnapUnit)EditorPrefs.GetInt(PreferenceKeys.GridUnit, 0); s_SyncUnitySnap = EditorPrefs.GetBool(PreferenceKeys.SyncUnitySnap, true); s_SnapMethod = (SnapMethod)EditorPrefs.GetInt(PreferenceKeys.SnapMethod, (int)Defaults.SnapMethod); s_IncreaseGridSize = EditorPrefs.HasKey(PreferenceKeys.IncreaseGridSize) ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.IncreaseGridSize) : KeyCode.Equals; s_DecreaseGridSize = EditorPrefs.HasKey(PreferenceKeys.DecreaseGridSize) ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.DecreaseGridSize) : KeyCode.Minus; s_NudgePerspectiveBackward = EditorPrefs.HasKey(PreferenceKeys.NudgePerspectiveBackward) ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.NudgePerspectiveBackward) : KeyCode.LeftBracket; s_NudgePerspectiveForward = EditorPrefs.HasKey(PreferenceKeys.NudgePerspectiveForward) ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.NudgePerspectiveForward) : KeyCode.RightBracket; s_NudgePerspectiveReset = EditorPrefs.HasKey(PreferenceKeys.ResetGridShortcutModifiers) ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.ResetGridShortcutModifiers) : KeyCode.Alpha0; s_CyclePerspective = EditorPrefs.HasKey(PreferenceKeys.CyclePerspective) ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.CyclePerspective) : KeyCode.Backslash; return(true); }
public static qb_Template LoadFromEditorPrefs(int slotIndex) { string prefix = "qbSettings_" + slotIndex.ToString() + "-"; if (!EditorPrefs.HasKey(prefix)) { return(null); } qb_Template template = new qb_Template(); //ScriptableObject.CreateInstance<qb_Template>();//new qb_Template(); template.brushName = EditorPrefs.GetString(prefix + "BrushName", template.brushName); template.lastKnownAs = EditorPrefs.GetString(prefix + "LastKnownAs", template.lastKnownAs); #region Brush Settings Vars template.brushRadius = EditorPrefs.GetFloat(prefix + "BrushRadius", template.brushRadius); //(float) propertyTable["BrushRadius"]; template.brushRadiusMin = EditorPrefs.GetFloat(prefix + "BrushRadiusMin", template.brushRadiusMin); //(float) propertyTable["BrushRadiusMin"]; template.brushRadiusMax = EditorPrefs.GetFloat(prefix + "BrushRadiusMax", template.brushRadiusMax); //(float) propertyTable["BrushRadiusMax"]; template.brushSpacing = EditorPrefs.GetFloat(prefix + "BrushSpacing", template.brushSpacing); //(float) propertyTable["BrushSpacing"]; template.brushSpacingMin = EditorPrefs.GetFloat(prefix + "BrushSpacingMin", template.brushSpacingMin); //(float) propertyTable["BrushSpacingMin"]; template.brushSpacingMax = EditorPrefs.GetFloat(prefix + "BrushSpacingMax", template.brushSpacingMax); //(float) propertyTable["BrushSpacingMax"]; template.scatterRadius = EditorPrefs.GetFloat(prefix + "ScatterRadius", template.scatterRadius); //(float) propertyTable["ScatterRadius"]; #endregion #region Rotation Settings Vars template.alignToNormal = EditorPrefs.GetBool(prefix + "AlignToNormal", template.alignToNormal); //(bool) propertyTable["AlignToNormal"]; template.flipNormalAlign = EditorPrefs.GetBool(prefix + "FlipNormalAlign", template.flipNormalAlign); //(bool) propertyTable["FlipNormalAlign"]; template.alignToStroke = EditorPrefs.GetBool(prefix + "AlignToStroke", template.alignToStroke); //(bool) propertyTable["AlignToStroke"]; template.flipStrokeAlign = EditorPrefs.GetBool(prefix + "FlipStrokeAlign", template.flipStrokeAlign); //(bool) propertyTable["FlipStrokeAlign"]; template.rotationRangeMin.x = EditorPrefs.GetFloat(prefix + "RotationRangeMinX", template.rotationRangeMin.x); //(float) propertyTable["RotationRangeMinX"]; template.rotationRangeMin.y = EditorPrefs.GetFloat(prefix + "RotationRangeMinY", template.rotationRangeMin.y); //(float) propertyTable["RotationRangeMinY"]; template.rotationRangeMin.z = EditorPrefs.GetFloat(prefix + "RotationRangeMinZ", template.rotationRangeMin.z); //(float) propertyTable["RotationRangeMinZ"]; template.rotationRangeMax.x = EditorPrefs.GetFloat(prefix + "RotationRangeMaxX", template.rotationRangeMax.x); //(float) propertyTable["RotationRangeMaxX"]; template.rotationRangeMax.y = EditorPrefs.GetFloat(prefix + "RotationRangeMaxY", template.rotationRangeMax.y); //(float) propertyTable["RotationRangeMaxY"]; template.rotationRangeMax.z = EditorPrefs.GetFloat(prefix + "RotationRangeMaxZ", template.rotationRangeMax.z); //(float) propertyTable["RotationRangeMaxZ"]; #endregion #region Position Settings Vars template.positionOffset.x = EditorPrefs.GetFloat(prefix + "PositionOffsetX", template.positionOffset.x); //(float) propertyTable["PositionOffsetX"]; template.positionOffset.y = EditorPrefs.GetFloat(prefix + "PositionOffsetY", template.positionOffset.y); //(float) propertyTable["PositionOffsetY"]; template.positionOffset.z = EditorPrefs.GetFloat(prefix + "PositionOffsetZ", template.positionOffset.z); //(float) propertyTable["PositionOffsetZ"]; #endregion #region Scale Settings Vars template.scaleAbsolute = EditorPrefs.GetBool(prefix + "ScaleAbsolute", template.scaleAbsolute); //The minimum and maximum possible scale template.scaleMin = EditorPrefs.GetFloat(prefix + "ScaleMin", template.scaleMin); //(float) propertyTable["ScaleMin"]; template.scaleMax = EditorPrefs.GetFloat(prefix + "ScaleMax", template.scaleMax); //(float) propertyTable["ScaleMax"]; //The minimum and maximum current scale range setting template.scaleRandMin.x = EditorPrefs.GetFloat(prefix + "ScaleRandMinX", template.scaleRandMin.x); //(float) propertyTable["ScaleRandMinX"]; template.scaleRandMin.y = EditorPrefs.GetFloat(prefix + "ScaleRandMinY", template.scaleRandMin.y); //(float) propertyTable["ScaleRandMinY"]; template.scaleRandMin.z = EditorPrefs.GetFloat(prefix + "ScaleRandMinZ", template.scaleRandMin.z); //(float) propertyTable["ScaleRandMinZ"]; template.scaleRandMax.x = EditorPrefs.GetFloat(prefix + "ScaleRandMaxX", template.scaleRandMax.x); //(float) propertyTable["ScaleRandMaxX"]; template.scaleRandMax.y = EditorPrefs.GetFloat(prefix + "ScaleRandMaxY", template.scaleRandMax.y); //(float) propertyTable["ScaleRandMaxY"]; template.scaleRandMax.z = EditorPrefs.GetFloat(prefix + "ScaleRandMaxZ", template.scaleRandMax.z); //(float) propertyTable["ScaleRandMaxZ"]; template.scaleRandMinUniform = EditorPrefs.GetFloat(prefix + "ScaleRandMinUniform", template.scaleRandMinUniform); //(float) propertyTable["ScaleRandMinUniform"]; template.scaleRandMaxUniform = EditorPrefs.GetFloat(prefix + "ScaleRandMaxUniform", template.scaleRandMaxUniform); //(float) propertyTable["ScaleRandMaxUniform"]; template.scaleUniform = EditorPrefs.GetBool(prefix + "ScaleUniform", template.scaleUniform); //(bool) propertyTable["ScaleUniform"]; #endregion #region Sorting Vars //Selection template.paintToSelection = EditorPrefs.GetBool(prefix + "PaintToSelection", template.paintToSelection); //(bool) propertyTable["PaintToSelection"]; //Layers template.paintToLayer = EditorPrefs.GetBool(prefix + "PaintToLayer", template.paintToLayer); //(bool) propertyTable["PaintToLayer"]; template.layerIndex = EditorPrefs.GetInt(prefix + "LayerIndex", template.layerIndex); //(int) propertyTable["LayerIndex"]; template.groupObjects = EditorPrefs.GetBool(prefix + "GroupObjects", template.groupObjects); //template.groupIndex = EditorPrefs.GetInt(prefix + "GroupIndex",template.groupIndex); template.groupName = EditorPrefs.GetString(prefix + "GroupName", template.groupName); #endregion #region Eraser Vars template.eraseByGroup = EditorPrefs.GetBool(prefix + "EraseByGroup", template.eraseByGroup); //(bool) propertyTable["EraseByGroup"]; template.eraseBySelected = EditorPrefs.GetBool(prefix + "EraseBySelected", template.eraseBySelected); //(bool) propertyTable["EraseBySelected"]; #endregion #region Repopulate the Prefab List string prefabGroupString = EditorPrefs.GetString(prefix + "PrefabGUIDList", string.Empty); // (string) propertyTable["PrefabGUIDList"]; qb_PrefabObject[] prefabGroup = new qb_PrefabObject[0]; string[] prefabStringList = new string[0]; List <UnityEngine.Object> newPrefabs = new List <UnityEngine.Object>(); if (prefabGroupString != string.Empty) { //first clear out any items that are in the prefab list now prefabGroup = new qb_PrefabObject[0]; //then retreive and split the saved prefab guids into a list prefabStringList = prefabGroupString.Split('/'); //string; } foreach (string prefabString in prefabStringList) { if (prefabString == string.Empty) { continue; } int splitIndex = prefabString.IndexOf("-"); string GUIDstring = string.Empty; string weightString = string.Empty; if (prefabString.Contains("-")) { GUIDstring = prefabString.Substring(0, splitIndex); weightString = prefabString.Substring(splitIndex + 1); } else { GUIDstring = prefabString; } if (GUIDstring == string.Empty) { continue; } float itemWeight = 1f; if (weightString != null && weightString != string.Empty) { itemWeight = System.Convert.ToSingle(weightString); } string assetPath = AssetDatabase.GUIDToAssetPath(GUIDstring); Object item = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)); if (item != null) { newPrefabs.Add(item); ArrayUtility.Add(ref prefabGroup, new qb_PrefabObject(item, itemWeight)); } } /* * if(newPrefabs.Count > 0) * { * foreach(UnityEngine.Object newPrefab in newPrefabs) * { * ArrayUtility.Add(ref prefabGroup,new qb_PrefabObject(newPrefab,1f)); * } * } */ template.prefabGroup = prefabGroup; #endregion #region Maintenance Vars template.dirty = EditorPrefs.GetBool(prefix + "Dirty", template.dirty); template.live = true; #endregion #region LiveVars template.active = EditorPrefs.GetBool(prefix + "Active", false); template.selectedPrefabIndex = EditorPrefs.GetInt(prefix + "SelectedPrefabIndex", -1); #endregion return(template); }
public void DrawGUI(Transform[] selectedTransforms) { if (m_TargetWrapper == null) { if (GUILayout.Button("Move Pivot")) { StartMove(); } if (!string.IsNullOrEmpty(m_ErrorMsg)) { EditorGUILayout.LabelField(m_ErrorMsg); } } else { if (GUILayout.Button("Stop Moving Pivot")) { Tools.current = m_prevTool; ResetTargets(); SceneView.RepaintAll(); } if (Tools.pivotMode == PivotMode.Center) { EditorGUILayout.Separator(); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.HelpBox("Be careful, the Unity tool handle is in 'Center' mode, which may be confusing.\nWe recommend you to work in 'Pivot' mode instead.", MessageType.Warning, true); if (GUILayout.Button("Switch to\n'Pivot' mode")) { Tools.pivotMode = PivotMode.Pivot; } } EditorGUILayout.Separator(); } if (m_TargetWrapper != null) { GUISelection(); m_TargetWrapper.GUIWorldPosition(); m_TargetWrapper.GUILocalPosition(); EditorGUILayout.Separator(); { EditorGUILayout.LabelField("Scene view", EditorStyles.boldLabel); using (new EditorGUILayout.HorizontalScope()) { EditorGUIUtility.labelWidth = 50f; m_Snap = EditorGUILayout.Toggle(ms_SnapGUIContent, EditorPrefs.GetBool(m_EditorPrefsPrefix + "SnapToggle", m_Snap)); EditorPrefs.SetBool(m_EditorPrefsPrefix + "SnapToggle", m_Snap); m_SnapGridSize = EditorGUILayout.FloatField(EditorPrefs.GetFloat(m_EditorPrefsPrefix + "SnapSize", m_SnapGridSize)); EditorPrefs.SetFloat(m_EditorPrefsPrefix + "SnapSize", m_SnapGridSize); } } } } }