/// <summary> /// Update the working grid. /// </summary> /// <param name="selectedGrid"></param> private void UpdateGridSelected(Grid3D selectedGrid) { if (selectedGrid != null) { if (FuncEditor.IsGameObjectInstancePrefab(selectedGrid.gameObject)) { if (EditorUtility.DisplayDialog("Modify Existing Grid Prefab", "The grid selected is a prefab and cannot be modified unless you unpack it. " + "\n Do you want to continue ?", "Yes", "No")) { PrefabUtility.UnpackPrefabInstance(selectedGrid.gameObject, PrefabUnpackMode.OutermostRoot, InteractionMode.UserAction); } else { selectedGrid = null; } } } else { _grid = null; } if (selectedGrid != null && selectedGrid != _grid) { _grid = selectedGrid; } }
public override void OnInspectorGUI() { DrawDefaultInspector(); EditorGUILayout.BeginVertical(); FuncEditor.DrawUILine(Color.gray, 1); foreach (Modifier modif in _map_modif.m_ModifiersList) { if (modif != null && !modif.Pass) { GUILayout.Label(modif.name, EditorStyles.boldLabel); FuncEditor.DrawUILine(Color.gray, 1); CreateEditor(modif).OnInspectorGUI(); } else if (modif != null && modif.Pass) { GUILayout.Label(modif.name + " is passed.", EditorStyles.boldLabel); modif.Pass = EditorGUILayout.Toggle(modif.Pass); } else { EditorGUILayout.HelpBox("Null modifier will be ignored.", MessageType.Warning); } FuncEditor.DrawUILine(Color.gray, 1); } EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { if (_grid.transform.hasChanged) { _grid.transform.localScale = Vector3.one; _grid.transform.localRotation = Quaternion.identity; } GUI.enabled = !Application.isPlaying; DrawDefaultInspector(); if (GUILayout.Button("Refresh")) { FuncEditor.RefreshGrid(_grid); } if (GUILayout.Button("Reset childs")) { FuncEditor.RefreshGrid(_grid); foreach (Core.Cell c in _grid.GetComponentsInChildren <Core.Cell>()) { c.ResetTransform(); } } GUI.enabled = true; if (GUILayout.Button("Show tools window")) { MapTileGridCreatorWindow.OpenWindows(); } }
private void StampInput() { if (Event.current.type == EventType.Layout) { HandleUtility.AddDefaultControl(0); } if (_selection.Count != 0) { //Preview destination Vector3 input = GetGridPositionInput(0.5f, _collide_with_plane); Vector3Int destination = _grid.GetIndexByPosition(ref input); DebugSelection(destination); //Apply stamp if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { Undo.SetCurrentGroupName("Stamp selected"); int group = Undo.GetCurrentGroup(); FuncEditor.StampCells(_selection, _grid, destination, _overwrite_cells_modif); Undo.CollapseUndoOperations(group); } //Reset selection else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { _mode_select = SelectMode.Default; } } }
private void EyedropperInput(MapTileGridCreator.Core.Cell selectedCell) { if (Event.current.type == EventType.Layout) { HandleUtility.AddDefaultControl(0); // Consume the event } //Select prefab from pallett and got to paint if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { GameObject prefabInstance = selectedCell.gameObject; GameObject prefab = FuncEditor.GetPrefabFromInstance(prefabInstance); int newIndex = _pallet.FindIndex(x => x.Equals(prefab)); if (newIndex >= 0) { _mode_paint = (int)PaintMode.Single; _pallet_index = newIndex; Debug.Log("Prefab " + prefab.name + " selected."); } else { Debug.LogError("Prefab is not from the pallet"); } } //Cancel else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { _mode_paint = PaintMode.Single; } }
protected override void AfterModify(Grid3D grid) { foreach (Vector3Int index in _to_instantiate) { FuncEditor.InstantiateCell(prefab, grid, index); } }
#pragma warning restore 0649 #endregion public override Queue <Vector3Int> Modify(Grid3D grid, Vector3Int index) { Core.Cell root; if ((root = grid.TryGetCellByIndex(ref index)) == null) { return(null); } Queue <Vector3Int> newIndexes = new Queue <Vector3Int>(); List <Core.Cell> neighb = grid.GetNeighboursCell(ref index); foreach (Core.Cell cell in neighb) { newIndexes.Enqueue(cell.GetIndex()); } //Modif Vector3Int upIndex = root.GetIndex() + grid.GetConnexAxes()[1]; if (!grid.HaveCell(ref upIndex)) { int height = Random.Range(Min_Random, Max_Random); GameObject prefab = FuncEditor.GetPrefabFromInstance(root.gameObject); for (int i = 0; i < height; i++) { if (!grid.HaveCell(ref upIndex)) { FuncEditor.InstantiateCell(prefab, grid, upIndex); } upIndex += grid.GetConnexAxes()[1]; } } return(newIndexes); }
protected override void AfterModify(Grid3D grid) { foreach (Cell c in _to_delete) { FuncEditor.DestroyCell(c); } last_index = last_index + Vector3Int.up; }
public void SetTargetObject(GameObject obj) { ActiveObj = obj; if (ActiveObj != null) { var sgs = ActiveObj.Resource.List <GLOB>(); if (sgs != null && sgs.Count > 0) { SemiglobalName = sgs[0].Name; SemiGlobalButton.Text = "Semi-Global (" + SemiglobalName + ")"; SemiGlobalButton.Enabled = true; } else { SemiglobalName = ""; SemiGlobalButton.Text = "Semi-Global"; SemiGlobalButton.Enabled = false; } } ObjThumb.ShowObject(obj.OBJ.GUID); IffResView.ChangeActiveObject(ActiveObj); FuncEditor.SetActiveObject(ActiveObj); DrawgroupEdit.SetActiveObject(ActiveObj); FSOMEdit.SetActiveObject(ActiveObj); XMLEdit.SetActiveObject(ActiveObj); PIFFEditor.SetActiveObject(ActiveObj); if (Content.Content.Get().Upgrades == null) { objPages.Controls.Remove(UpgradeTab); } else { UpgradeEditor.SetActiveObject(ActiveObj); } //update top var ObjNameLabel.Text = obj.OBJ.ChunkLabel; ObjDescLabel.Text = "§----"; if (obj.OBJ.MasterID == 0) { ObjMultitileLabel.Text = "Single-tile object."; } else if (obj.OBJ.SubIndex < 0) { ObjMultitileLabel.Text = "Multitile master object."; } else { ObjMultitileLabel.Text = "Multitile part. (" + (obj.OBJ.SubIndex >> 8) + ", " + (obj.OBJ.SubIndex & 0xFF) + ")"; } DefinitionEditor.UpdateOBJD(ActiveObj); }
public Core.Cell ToCell(Grid3D grid) { GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(_pathPrefab); Core.Cell cell = FuncEditor.InstantiateCell(prefab, grid, _index); cell.transform.localPosition = _localposition; cell.transform.localRotation = Quaternion.Euler(_localrotation); cell.transform.localScale = _localscale; return(cell); }
public CellDTO(Core.Cell cell) { GameObject prefab = FuncEditor.GetPrefabFromInstance(cell.gameObject); _pathPrefab = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(prefab); _index = cell.GetIndex(); _localposition = cell.transform.localPosition; _localrotation = cell.transform.localRotation.eulerAngles; _localscale = cell.transform.localScale; }
private void PaintInput(Vector3 pointWorld) { if (Event.current.type == EventType.Layout) { HandleUtility.AddDefaultControl(0); } //Apply paint if (_pallet_index < _pallet.Count && Event.current.type == EventType.MouseDown && Event.current.button == 0) { GameObject prefab = _pallet[_pallet_index]; FuncEditor.InstantiateCell(prefab, _grid, pointWorld); } }
private void OnFocus() { /* 2018.4.22f1 * SceneView.onSceneGUIDelegate -= OnSceneGUI; * SceneView.onSceneGUIDelegate += OnSceneGUI; */ SceneView.duringSceneGui -= OnSceneGUI; SceneView.duringSceneGui += OnSceneGUI; if (_grid != null) { FuncEditor.RefreshGrid(_grid); } RefreshPallet(); }
public Grid3D ToGrid3D() { Grid3D grid = FuncEditor.InstantiateGrid3D(_type); grid.name = _name; grid.SizeCell = _size_cell; grid.GapRatio = _gap; foreach (CellDTO celldto in _map) { celldto.ToCell(grid); } return(grid); }
private void OnSceneGUI(SceneView sceneView) { SelectionGridSceneView(); OnSelectionEditChangedCheck(); if (_grid != null) { //Update grid debug position Vector3 positionGrid = _grid.Origin; positionGrid.y += _offset_grid_y; _plane_y.SetNormalAndPosition(_grid.GetAxe(1), positionGrid); SwitchEditMode(); if (_debug_grid) { FuncEditor.DebugGrid(_grid, DebugsColor.grid_help, _offset_grid_y, _size_grid); } } }
/// <summary> /// Test selection for auto link grid to the window. /// </summary> public void SelectionGridSceneView() { GameObject select = Selection.activeGameObject; if (select != null) { Grid3D grid = null; if (FuncEditor.IsGameObjectSceneView(select)) { grid = select.GetComponent <Grid3D>(); if (grid == null) { MapTileGridCreator.Core.Cell cell = select.GetComponent <MapTileGridCreator.Core.Cell>(); grid = cell != null?cell.GetGridParent() : null; } } if (grid != null) { UpdateGridSelected(grid); } } }
//////////////////////////////////////// // Select differents modes private void MoveInput() { if (Event.current.type == EventType.Layout) { HandleUtility.AddDefaultControl(0); } if (_selection.Count != 0) { //Preview destination Vector3 input = GetGridPositionInput(0.5f, _collide_with_plane); Vector3Int destination = _grid.GetIndexByPosition(ref input); DebugSelection(destination); //Move apply if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { Undo.SetCurrentGroupName("Move selected"); int group = Undo.GetCurrentGroup(); FuncEditor.StampCells(_selection, _grid, destination, _overwrite_cells_modif); foreach (MapTileGridCreator.Core.Cell c in _selection) { Undo.DestroyObjectImmediate(c.gameObject); } Undo.CollapseUndoOperations(group); _mode_select = SelectMode.Default; Selection.SetActiveObjectWithContext(_grid.gameObject, null); } //Reset selection else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { _mode_select = SelectMode.Default; } } }
public void OnEnable() { _grid = (Grid3D)target; FuncEditor.RefreshGrid(_grid); }