public override void OnInspectorGUI() { Transform transform = (Transform)target; // Make this Undo-able Undo.RecordObject(transform, "Transform Custom Update"); EditorGUILayout.BeginVertical(); // position EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Position", GUILayout.MaxWidth(labelWidth)); positionState = (RelativeState)EditorGUILayout.EnumPopup(positionState); if (positionState == RelativeState.Global) { transform.position = EditorGUILayout.Vector3Field("", CMath.RoundToPoint(transform.position, roundPlaces)); } else { transform.localPosition = EditorGUILayout.Vector3Field("", CMath.RoundToPoint(transform.localPosition, roundPlaces)); } EditorGUILayout.EndHorizontal(); // rotation EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Rotation", GUILayout.MaxWidth(labelWidth)); rotationState = (RelativeState)EditorGUILayout.EnumPopup(rotationState); if (rotationState == RelativeState.Global) { transform.eulerAngles = EditorGUILayout.Vector3Field("", CMath.RoundToPoint(transform.eulerAngles, roundPlaces)); } else { transform.localEulerAngles = EditorGUILayout.Vector3Field("", CMath.RoundToPoint(transform.localEulerAngles, roundPlaces)); } EditorGUILayout.EndHorizontal(); // scale EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Scale", GUILayout.MaxWidth(labelWidth)); scaleState = (RelativeState)EditorGUILayout.EnumPopup(scaleState); if (scaleState == RelativeState.Global) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.Vector3Field("", CMath.RoundToPoint(transform.lossyScale, roundPlaces)); // can't set global scale EditorGUI.EndDisabledGroup(); } else { transform.localScale = EditorGUILayout.Vector3Field("", CMath.RoundToPoint(transform.localScale, roundPlaces)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
private void PatchProjectExplorer(ProjectFinalizer project) { if (project.ReferencingAssemblies.Count == 0 || project.ReferencingAssemblies.Count > 100) { return; } var fileName = Path.Combine(project.ProjectDestinationFolder, Constants.ProjectExplorer + ".html"); if (!File.Exists(fileName)) { return; } var sourceLines = File.ReadAllLines(fileName); List <string> lines = new List <string>(sourceLines.Length + project.ReferencingAssemblies.Count + 2); RelativeState state = RelativeState.Before; foreach (var sourceLine in sourceLines) { switch (state) { case RelativeState.Before: if (sourceLine == "<div class=\"folderTitle\">References</div><div class=\"folder\">") { state = RelativeState.Inside; } break; case RelativeState.Inside: if (sourceLine == "</div>") { state = RelativeState.InsertionPoint; } break; case RelativeState.InsertionPoint: lines.Add("<div class=\"folderTitle\">Used By</div><div class=\"folder\">"); foreach (var referencingAssembly in project.ReferencingAssemblies) { string referenceHtml = Markup.GetProjectExplorerReference("/#" + referencingAssembly, referencingAssembly); lines.Add(referenceHtml); } lines.Add("</div>"); state = RelativeState.After; break; case RelativeState.After: break; default: break; } lines.Add(sourceLine); } File.WriteAllLines(fileName, lines); }