private void Awake() { try { InitializeGui(); InitializeVariables(); InitializeMaterial(); InitializeEditorGizmo(); InitializeInteractions(); EditorMethods.LoadFavourites(); Invoke("LoadBlueprintsDelayed", 3); } catch (System.Exception ex) { ModAPI.Log.Write(ex.ToString()); } }
public override void JustSave() { base.JustSave(); EditorMethods.SaveBlueprints(); }
private void LoadBlueprintsDelayed() { EditorMethods.LoadBlueprints(); }
public void Update() { try { if (EditorVariables.isEditing) { if (UnityEngine.Input.GetMouseButtonDown(1)) { if (isMoving) { isMoving = false; } else { EditorMethods.DisableEditing(); } } if (ModAPI.Input.GetButtonDown("Toggle")) { if (UnityEngine.Input.GetKey(KeyCode.LeftShift)) { ChangeEditMode(); } ChangeEditMode(); } //displaying gizmos if (EditorVariables.EditedTransform != null) { transform.position = EditorVariables.EditedTransform.position; if (EditorVariables.EditMode == EditorVariables.EditModes.Position) { transform.rotation = Quaternion.identity; } else { transform.rotation = EditorVariables.EditedTransform.rotation; } //editing the obj transform SelectGizmo(); ReleaseGizmo(); if (draggingGizmo) { //DragGizmo(); } else { if (EditorVariables.SelectedGizmo != Gizmo.GizmoTypes.None) { EditTransform(); } else { // ModAPI.Console.Write("no selected gizmo"); } } } else { EditorVariables.isEditing = false; } } else { transform.position = Vector3.up * -10000; } } catch (System.Exception ex) { ModAPI.Log.Write(ex.ToString()); } }
private void DrawDetailMenu() { ListItem item = EditorVariables.SelectedListItem; ///////////////////////////////////Image GUI.DrawTexture(DetailImageRect, item.Image); /////////////////////////////////////////////////////////// ///////////////////////////////////name GUIStyle NameStyle = new GUIStyle(GUI.skin.label) { fontSize = Mathf.RoundToInt(40 * Ratio), alignment = TextAnchor.UpperCenter, fontStyle = FontStyle.Italic }; GUILayout.BeginArea(DetailNameRect); GUILayout.Label(titleImage, NameStyle, GUILayout.Height(70)); GUILayout.Label(item.Name, NameStyle); GUILayout.EndArea(); //////////////////////////////////////////////////////////// ///////////////////////////////////recipe GUIStyle RecipeStyle = new GUIStyle(GUI.skin.label) { fontSize = Mathf.RoundToInt(25 * Ratio), alignment = TextAnchor.UpperRight }; GUILayout.BeginArea(DetailRecipeRect, RecipeStyle); GUILayout.Label(recipeImage, RecipeStyle, GUILayout.Height(60)); foreach (KeyValuePair <int, int> pair in item.Ingredients) { string ItemName = ItemDatabase.ItemById(pair.Key)._name; GUILayout.Label(" " + ItemName + " x" + pair.Value, RecipeStyle); } GUILayout.EndArea(); //////////////////////////////////////////////////////////// ///////////////////////////////////description GUIStyle DescStyle = new GUIStyle(GUI.skin.label) { fontSize = Mathf.RoundToInt(26 * Ratio), alignment = TextAnchor.UpperCenter }; GUI.Label(DetailDescRect, item.Description, DescStyle); //////////////////////////////////////////////////////////// ///////////////////////////////////info GUIStyle InfoStyle = new GUIStyle(GUI.skin.label) { fontSize = Mathf.RoundToInt(28 * Ratio), alignment = TextAnchor.UpperLeft, }; GUILayout.BeginArea(DetailInfoRect); GUILayout.Label("Author", InfoStyle); GUILayout.Label(item.AuthorName, InfoStyle); GUILayout.Space(30 * Ratio); GUILayout.Label("Category", InfoStyle); GUILayout.Label(item.Category, InfoStyle); GUILayout.Space(30 * Ratio); GUILayout.Label("Mod name", InfoStyle); GUILayout.Label(item.ModName, InfoStyle); GUILayout.EndArea(); //////////////////////////////////////////////////////////// ///////////////////////////////////favourite button if (EditorVariables.FavouriteItems.Contains(EditorVariables.SelectedListItemIndex)) { if (GUI.Button(DetailFavouriteRect, favouriteON)) { if (DetailFavouriteRect.Contains(new Vector2(UnityEngine.Input.mousePosition.x, Screen.height - UnityEngine.Input.mousePosition.y))) { EditorVariables.FavouriteItems.Remove(EditorVariables.SelectedListItemIndex); EditorMethods.SaveFavourites(); } } } else { if (GUI.Button(DetailFavouriteRect, favouriteOFF)) { EditorVariables.FavouriteItems.Add(EditorVariables.SelectedListItemIndex); EditorMethods.SaveFavourites(); } } //////////////////////////////////////////////////////////// ///////////////////////////////////place blueprint button if (GUI.Button(DetailImageRect, "", RecipeStyle)) { EditorMethods.PlaceBlueprint(); } }
private void DrawBlueprintMenu() { Blueprint b = EditorVariables.pInteraction.GetLookAtBlueprint(); if (b != null && !b.Finished) { float Dist = Vector3.Distance(LocalPlayer.Transform.position, b.transform.position); Rect rect = new Rect(RecipeRect); rect.size = new Vector2(rect.width / Dist, rect.height / Dist); Vector2 center = LocalPlayer.MainCam.WorldToScreenPoint(b.transform.position); rect.center = new Vector2(center.x, Screen.height - center.y); GUIStyle boxStyle = new GUIStyle(GUI.skin.box); GUILayout.BeginArea(rect, boxStyle); GUIStyle recipeStyle = new GUIStyle(GUI.skin.label) { fontSize = Mathf.RoundToInt(140 / Dist), alignment = TextAnchor.LowerCenter }; GUILayout.Label(b.vars.ItemOnList.Name, recipeStyle); foreach (KeyValuePair <int, int> pair in b.vars.Recipe.Ingredients) { string ItemName = ItemDatabase.ItemById(pair.Key)._name; GUILayout.Label(" " + ItemName + " x" + pair.Value, recipeStyle); } GUILayout.EndArea(); GUI.DrawTexture(new Rect(rect.x, rect.yMax, rect.width * (EditorVariables.TimeToRemove / EditorVariables.MaxTimeToRemove), 20 * Ratio), RemoveImage); if (ModAPI.Input.GetButton("Delete")) { EditorVariables.TimeToRemove = Mathf.Clamp(EditorVariables.TimeToRemove + Time.deltaTime, 0, EditorVariables.MaxTimeToRemove); if (EditorVariables.TimeToRemove >= EditorVariables.MaxTimeToRemove) { EditorVariables.SerializableBlueprints.Remove(b.vars.Index); Core.Remove(b.gameObject); EditorVariables.TimeToRemove = 0; } } else { EditorVariables.TimeToRemove = 0; } if (ModAPI.Input.GetButtonDown("Put")) { if (b.vars.Recipe.PlaceItem()) { // play audio } } else if (ModAPI.Input.GetButtonDown("Edit")) { if (UnityEngine.Input.GetKey(KeyCode.LeftShift)) { GameObject obj = EditorMethods.PlaceBlueprint(b.vars.ItemOnList.PrefabID, EditorVariables.pInteraction.GetLookAtPos()); obj.transform.localScale = b.transform.localScale; obj.transform.rotation = b.transform.rotation; } else { } EditorMethods.EnableEditing(b); } } }