public EditorState() { _tool = EditorTool.Spiro; _mode = EditorMode.Create; _displayKnots = true; _displayGuides = true; _snapX = 15.0; _snapY = 15.0; _enableSnap = true; _shape = null; _hitTreshold = 7; _hitTresholdSquared = 49; _hitSetShapes = new HashSet<SpiroShape>(); _hitSetPoints = new HashSet<int>(); _hitListShapes = new ObservableCollection<SpiroShape>(); _hitListPoints = new ObservableCollection<int>(); _isStroked = true; _isFilled = false; _isClosed = true; _isTagged = false; _pointType = SpiroPointType.G4; _isCaptured = false; _snapTreshold = 10.0; _snapMode = GuideSnapMode.Point | GuideSnapMode.Middle | GuideSnapMode.Intersection | GuideSnapMode.Horizontal | GuideSnapMode.Vertical; _snapPointRadius = 3.5; _snapPoint = default(GuidePoint); _haveSnapPoint = false; }
public static bool BuildShaderBundle(BundleData bundle, BundleState state) { if (bundle == null || state == null) { return(false); } List <UnityEngine.Object> list = new List <UnityEngine.Object>(); for (int i = 0; i < bundle.includs.Count; ++i) { string path = bundle.includs[i]; if (path.StartsWith("Assets", StringComparison.OrdinalIgnoreCase)) { UnityEngine.Object[] assetsAtPath = AssetDatabase.LoadAllAssetsAtPath(path); if (assetsAtPath != null || assetsAtPath.Length != 0) { list.AddRange(assetsAtPath); } else { Debug.LogError("Cannnot load [" + path + "] as asset object"); } } else { UnityEngine.Object obj = Shader.Find(path); if (obj == null) { Debug.LogError("Find shader " + path + " failed."); } else { list.Add(obj); } } } if (list.Count == 0) { Debug.LogError("Empty Shader Bundle " + bundle.name); return(false); } uint crc = 0; string outputPath = BuildConfig.GetBuildOutputPath(bundle.name); EditorTool.CreateDirectory(outputPath); bool succeed = BuildAssetBundle(list.ToArray(), outputPath, out crc); succeed = UpdateBundleState(bundle, state, outputPath, succeed, crc); return(succeed); }
public static TextureInfo CreateTextureInfo(string assetPath) { if (!EditorPath.IsTexture(assetPath)) { return(null); } TextureInfo textureInfo = null; if (!_dictTexInfo.TryGetValue(assetPath, out textureInfo)) { textureInfo = new TextureInfo(); _dictTexInfo.Add(assetPath, textureInfo); } TextureImporter textureImport = AssetImporter.GetAtPath(assetPath) as TextureImporter; Texture texture = AssetDatabase.LoadAssetAtPath <Texture>(assetPath); if (textureImport == null || texture == null) { return(null); } textureInfo.Path = textureImport.assetPath; textureInfo.ImportType = textureImport.textureType; textureInfo.ImportShape = textureImport.textureShape; textureInfo.ReadWriteEnable = textureImport.isReadable; textureInfo.MipmapEnable = textureImport.mipmapEnabled; textureInfo.WrapMode = textureImport.wrapMode; textureInfo.FilterMode = textureImport.filterMode; textureInfo.StandaloneFormat = EditorTool.GetPlatformTextureSettings(textureImport, EditorConst.PlatformStandalone); textureInfo.AndroidFormat = EditorTool.GetPlatformTextureSettings(textureImport, EditorConst.PlatformAndroid); textureInfo.IosFormat = EditorTool.GetPlatformTextureSettings(textureImport, EditorConst.PlatformIos); textureInfo.StandaloneOverriden = EditorTool.IsTextureOverriden(textureImport, EditorConst.PlatformStandalone); textureInfo.AndroidOverriden = EditorTool.IsTextureOverriden(textureImport, EditorConst.PlatformAndroid); textureInfo.IosOverriden = EditorTool.IsTextureOverriden(textureImport, EditorConst.PlatformIos); textureInfo.StandaloneSize = EditorTool.CalculateTextureSizeBytes(texture, textureInfo.StandaloneFormat); textureInfo.AndroidSize = EditorTool.CalculateTextureSizeBytes(texture, textureInfo.AndroidFormat); textureInfo.IosSize = EditorTool.CalculateTextureSizeBytes(texture, textureInfo.IosFormat); textureInfo.MemSize = Mathf.Max(textureInfo.StandaloneSize, textureInfo.AndroidSize, textureInfo.IosSize); textureInfo.Width = texture.width; textureInfo.Height = texture.height; if (Selection.activeObject != texture) { Resources.UnloadAsset(texture); } if (++_loadCount % 256 == 0) { Resources.UnloadUnusedAssets(); } return(textureInfo); }
public override void OnInspectorGUI() { DrawDefaultInspector(); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(_lockCursor, new GUIContent("Lock Cursor")); if (GUI.changed) { serializedTarget.lockCursor = _lockCursor.boolValue; } EditorGUILayout.PropertyField(lockToTransform); GUILayout.EndHorizontal(); EditorTool.AddSpecialSpace(0); EditorGUILayout.LabelField("Movement Settings", new GUIStyle("BoldLabel")); EditorGUI.indentLevel++; EditorTool.MakeMinMaxSlider(minDistance, maxDistance, 0, 100, "Distance Clamp"); EditorGUILayout.Slider(currentDistance, minDistance.floatValue, maxDistance.floatValue); EditorGUILayout.Slider(collisionMargin, -(maxDistance.floatValue - minDistance.floatValue) / 2, (maxDistance.floatValue - minDistance.floatValue) / 2); EditorGUILayout.PropertyField(collisionMask); EditorGUILayout.Slider(zoomSpeed, -25, 25); EditorGUILayout.Slider(movementSmoothness, 0f, 1, "Smoothness"); EditorGUI.indentLevel--; EditorTool.AddSpecialSpace(0); EditorGUILayout.LabelField("Rotation Settings", new GUIStyle("BoldLabel")); Vector3 rotations = new Vector3(pitch.floatValue, yaw.floatValue, roll.floatValue); Rect buttonRect = GUILayoutUtility.GetLastRect(); buttonRect.x += EditorGUIUtility.labelWidth; buttonRect.width -= EditorGUIUtility.labelWidth; if (GUI.Button(buttonRect, "Calculate Initial Rotation")) { if (objective.objectReferenceValue != null) { var objectiveTransform = objective.objectReferenceValue as Transform; var rotation = serializedTarget.transform.rotation; serializedTarget.transform.LookAt(objectiveTransform.position + objectiveOffset.vector3Value); rotations = serializedTarget.transform.rotation.eulerAngles; serializedTarget.transform.rotation = rotation; pitch.floatValue = rotations.x; yaw.floatValue = rotations.y; roll.floatValue = rotations.z; } } EditorGUI.indentLevel++; EditorTool.MakeMinMaxSlider(minPitch, maxPitch, -180, 180, "Pitch Clamp"); rotationSpeed.vector3Value = EditorGUILayout.Vector3Field(rotationSpeed.displayName, rotationSpeed.vector3Value); rotations = EditorGUILayout.Vector3Field("Rotations", rotations); if (GUI.changed) { pitch.floatValue = rotations.x; yaw.floatValue = rotations.y; roll.floatValue = rotations.z; } EditorGUILayout.Slider(rotationSmoothness, 0f, 0.5f, "Smoothness"); GUI.enabled = objective.objectReferenceValue; GUI.enabled = true; EditorGUI.indentLevel--; serializedObject.ApplyModifiedProperties(); }
public GameObject LoadNpc(MapNpc npc, Vector3 pos) { string fxname = npc.modelId; Object prefab = EditorTool.LoadAssetBundle("model/" + fxname); if (prefab == null) { Debug.LogError("npc 资源找不到:" + fxname); npc.modelId = "n_fujiaertongnv"; fxname = npc.modelId; prefab = EditorTool.LoadAssetBundle("model/" + fxname); } string subpath = "npc"; switch (npc.type) { case 1: subpath = "monster"; break; default: subpath = "npc"; break; } Transform parentTrans = getRoot().FindChild(subpath); if (parentTrans == null) { GameObject subroot = new GameObject(subpath); subroot.transform.SetParent(getRoot()); parentTrans = subroot.transform; } string nodeName = "npc_" + npc.uniqueId; GameObject npcObj = (GameObject)GameObject.Instantiate(prefab); GameObject npcCont = new GameObject(nodeName); npcObj.transform.SetParent(npcCont.transform); npcObj.transform.localPosition = Vector3.zero; npcCont.transform.SetParent(parentTrans); //x y坐标 npcCont.transform.localPosition = pos; //direction 是弧度 * 1000 只记了y方向的旋转 //npcCont.transform.localRotation.eulerAngles = new Vector3(0,npc.direction / 1000 / 2 / Mathf.PI * 360,0); MapNpcView view = npcCont.AddComponent <MapNpcView>(); view.data = npc; npc.target = npcCont; return(npcCont); }
protected override void DrawChildProperties(Rect position, SerializedProperty property) { Rect newPosition = DrawTopLabel(position); //draw unique id newPosition = DrawUniqueID(newPosition); //draw name newPosition = EditorTool.DrawTextField(newPosition, name, "Name"); //draw data array newPosition = EditorTool.DrawReorderableList(newPosition, reorderableList, "Myths"); }
private void DrawToolbarGUI() { Rect rect = new Rect(0, 0, Screen.width, 50f); //rect.height = 50f; GUILayout.BeginArea(rect, MapEditor.toolbar); GUILayout.BeginHorizontal(); //float curToolbarWidth = 0; //if (isEditorMap) { if (GUILayout.Button("File", MapEditor.toolbarDropdown, GUILayout.Width(50))) { GenericMenu menu = new UnityEditor.GenericMenu(); //menu.AddSeparator(""); menu.AddItem(new GUIContent("LoadTex"), false, () => { MapEditor.BgTexture = EditorTool.LoadTexture(); }); //menu.DropDown(new Rect(0, 0, 20, 30)); menu.ShowAsContext(); } if (GUILayout.Button("工具", MapEditor.toolbarDropdown, GUILayout.Width(75))) { GenericMenu menu = new UnityEditor.GenericMenu(); //menu.AddSeparator(""); menu.AddItem(new GUIContent("鼠标"), false, () => { this.SetState(0); }); menu.AddItem(new GUIContent("笔刷"), false, () => { this.SetState(1); }); menu.AddItem(new GUIContent("移动"), false, () => { this.SetState(2); }); //menu.DropDown(new Rect(0, 0, 20, 30)); menu.ShowAsContext(); } string state = GetToolName();//new GUIContent(state, "当前编辑状态") GUILayout.Label("当前编辑状态:" + state, GUILayout.Width(200)); } if ((Pagetype == PageType.Editor || Pagetype == PageType.EditorSub) && EditorType == ToolType.Brush) { if (GUILayout.Button("选择格子类型", MapEditor.toolbarDropdown, GUILayout.Width(100))) { GenericMenu menu = new UnityEditor.GenericMenu(); //menu.AddSeparator(""); menu.AddItem(new GUIContent("不可见"), false, () => { this.SetCellType(0); }); menu.AddItem(new GUIContent("阻挡"), false, () => { this.SetCellType(1); }); menu.AddItem(new GUIContent("可编辑"), false, () => { this.SetCellType(2); }); //menu.DropDown(new Rect(0, 0, 20, 30)); menu.ShowAsContext(); } string state = GetCellName();//new GUIContent(state, "当前编辑状态") GUILayout.Label("选定格子:" + state); } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
private Graph NewAsAsset() { var newGraph = (Graph)EditorTool.CreateAsset(typeof(UIGraph), true); if (newGraph != null) { EditorUtility.SetDirty(newGraph); AssetDatabase.SaveAssets(); } return(newGraph); }
protected override void DrawChildProperties(Rect position, SerializedProperty property) { Rect newPosition = new Rect(position.x, position.y, position.width, 0F); //draw unique id newPosition = DrawUniqueID(newPosition); //draw name newPosition = EditorTool.DrawTextField(newPosition, name, "Name"); //draw id newPosition = EditorTool.DrawIntField(newPosition, maxValue, "Max Value"); }
public void SaveSetting() { string time = DateTime.Now.ToString(); string timeFilePath = Application.streamingAssetsPath + "/time.txt"; File.WriteAllText(timeFilePath, time, Encoding.UTF8); string jsonStr = JsonUtility.ToJson(setting, true); EditorTool.WriteFileWithCode(SettingPath, jsonStr, null); EnCodeSetting(); }
public static void SaveData() { if (m_datas != null) { EditorTool.SaveJsonData <List <BundleData> >(m_datas, BuildConfig.BundleDataPath); } if (m_states != null) { EditorTool.SaveJsonData <List <BundleState> >(m_states, BuildConfig.BundleStatePath); } }
public void SaveKeystoreSetting() { PlayerSettings.productName = setting.appName; PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android | BuildTargetGroup.iOS | BuildTargetGroup.Standalone, keystoreCnf.bundleIdentifier); PlayerSettings.bundleVersion = setting.version; PlayerSettings.Android.keystoreName = keystoreCnf.keystore; PlayerSettings.Android.keystorePass = keystoreCnf.keypass; PlayerSettings.Android.keyaliasName = keystoreCnf.keyaliname; PlayerSettings.Android.keyaliasPass = keystoreCnf.keyalipass; EditorTool.WriteFileWithCode(KeystorePath, LitJson.JsonMapper.ToJson(keystoreCnf), Encoding.UTF8); }
//called from base OnGUI, handles child property drawing protected override void DrawChildProperties(Rect position, SerializedProperty property) { //draw label Rect newPosition = DrawTopLabel(position); //draw unique id newPosition = DrawUniqueID(newPosition); //Draw name newPosition = EditorTool.DrawTextField(newPosition, name, "Text"); //Draw tag newPosition = DrawTag(newPosition); }
//called from base OnGUI, handles child property drawing protected override void DrawChildProperties(Rect position, SerializedProperty property) { //draw label Rect newPosition = DrawTopLabel(position); //draw unique id newPosition = DrawUniqueID(newPosition); //draw name field newPosition = EditorTool.DrawTextField(newPosition, name, "Name"); //draw lines newPosition = EditorTool.DrawReorderableList(newPosition, linesList, "Lines"); }
public static void GenerateCode() { List <string> uiPrefabs = EditorTool.AssetPathOfUnityFolder("Resources/" + WindowFactory.WindowPrefabPath, ".prefab"); foreach (var v in uiPrefabs) { var goPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(v); windowTypes.Add(goPrefab.name); //writeWindowBase(goPrefab.name); } writeWindowType(); }
public void DoTool(EditorTool tool) { switch (tool) { case EditorTool.PLACE: if (CanPlace && Input.GetMouseButtonDown(0)) { PlaceTile(Tile.GetTile(ID), MouseX, MouseY); } else if (Input.GetMouseButtonDown(1)) { PlaceTile(null, MouseX, MouseY); } break; case EditorTool.MAKE_SLANTED: var tile = Target.GetTile(MouseX, MouseY); if (tile == null) { CurrentColour = CannotPlaceColour; break; } if (!(tile is ConnectedTile)) { CurrentColour = WarnColour; break; } bool canBeSlanted = tile.CanBeSlanted(); if (!canBeSlanted) { CurrentColour = WarnColour; break; } if (CanPlace && Input.GetMouseButtonDown(0)) { var ct = tile as ConnectedTile; bool s = !InputManager.IsPressed("Alternative Tool Use"); if (ct.Slanted != s) { ct.Slanted = s; ct.RefreshTexture(); Target.UpdateSurroundingsRadial(ct.X, ct.Y); } } break; } }
public GameObject AddTrigger(MapTrigger trigger, Vector3 pos) { Object prefab = EditorTool.LoadAssetBundle("model/scene_portal_e.unity3d"); if (prefab == null) { Debug.LogError("传送门 资源找不到:model/scene_portal_e.unity3d"); return(null); } string subpath = "trigger"; Transform parentTrans = getRoot().FindChild(subpath); if (parentTrans == null) { GameObject subroot = new GameObject(subpath); subroot.transform.SetParent(getRoot()); parentTrans = subroot.transform; } string nodeName = "trigger_" + trigger.id; GameObject npcObj = (GameObject)GameObject.Instantiate(prefab); npcObj.name = nodeName; npcObj.transform.SetParent(parentTrans); npcObj.transform.localPosition = pos; if (trigger.eulerangles != null) { string[] arr = trigger.eulerangles.Split(','); if (arr.Length == 3) { //npcObj.transform.Rotate(float.Parse(arr[0]), float.Parse(arr[1]), float.Parse(arr[2])); npcObj.transform.localRotation = Quaternion.Euler(float.Parse(arr[0]), float.Parse(arr[1]), float.Parse(arr[2])); } } MapTriggerView view = npcObj.AddComponent <MapTriggerView>(); view.data = trigger; foreach (ParticleSystem ps in npcObj.GetComponentsInChildren <ParticleSystem>()) { ps.Play(true); } trigger.target = npcObj; return(npcObj); }
//called from base OnGUI, handles child property drawing protected override void DrawChildProperties(Rect position, SerializedProperty property) { //ensure all properties set SetProperties(property); //draw defaults label Rect newPostion = EditorTool.DrawTopLabel(position, "Defaults"); //draw continue text newPostion = EditorTool.DrawTextField(newPostion, continueText, "Reply"); //draw end text newPostion = EditorTool.DrawTextField(newPostion, endText, "Last Reply"); }
//called from base OnGUI, handles child property drawing protected override void DrawChildProperties(Rect position, SerializedProperty property) { //draw label Rect newPosition = DrawTopLabel(position); //draw unique id newPosition = DrawUniqueID(newPosition); //draw defaults newPosition = EditorTool.DrawTextField(newPosition, defaultRepy, "Default Reply"); newPosition = EditorTool.DrawTextField(newPosition, defaultEndReply, "Default End Reply"); //draw conversations newPosition = EditorTool.DrawReorderableList(newPosition, reorderableList, "Conversations"); }
/// <summary> /// 移除连接线 /// </summary> /// <param name="connection"></param> /// <param name="recordUndo"></param> public void RemoveConnection(Connection connection, bool recordUndo = true) { if (recordUndo) { EditorTool.RecordUndo(this, "Delete Connection"); } connection.OnDestroy(); connection.sourceNode.outConnections.Remove(connection); connection.targetNode.inConnections.Remove(connection); connection.targetNode.OnDisConnection(); currentSelection = null; UpdateNodeIDs(false); }
private void Init() { string stylePrePath = string.Format("{0}/CreatAssetBundle/", Application.dataPath); BuildAssetBundles.Pack(stylePrePath + "PlatformLobby/DataTable", "DataTable"); //以Assets目录创建根对象 _asset = new AssetInfo(Application.dataPath + "/CreatAssetBundle", "CreatAssetBundle", true); //从根对象开始,读取所有文件创建子对象 EditorTool.ReadAssetsInChildren(_asset); Resources.UnloadUnusedAssets(); }
public virtual void RefreshDataWithSelect() { for (int i = 0; i < m_dataList.Count; ++i) { m_dataList[i].ClearObject(); m_dataList[i].Index = i; } if (m_dataTable != null) { m_dataTable.RefreshData(EditorTool.ToObjectList <T>(m_dataList)); } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { SetProperties(property); float totalHeight = 0F; //unique id totalHeight += EditorTool.AddedLineHeight; //name totalHeight += EditorTool.GetAddedHeight(EditorTool.GetHeight(name)); //id totalHeight += EditorTool.AddedLineHeight; return(totalHeight); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (!skin) { skin = Resources.Load("skin") as GUISkin; } if (!stateManager) { stateManager = (GameStateGraph)EditorTool.GetAssetOfType(typeof(GameStateGraph), ".asset"); if (!stateManager) { if (EditorUtility.DisplayDialog("配置游戏状态管理器", "第一次需要配置游戏状态管理器!", "确定", "不要取消")) { stateManager = (GameStateGraph)this.NewAsAsset(); } else { stateManager = (GameStateGraph)this.NewAsAsset(); } } } GUI.skin = skin; GUILayout.BeginVertical("游戏状态管理器", "window"); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); GUILayout.Space(10); EditorGUILayout.HelpBox("游戏状态管理器是管理每个游戏状态的进入和离开,比如登录状态,创建角色状态等等", MessageType.Info); GUILayout.Space(10); if (GraphWindow.IsClosed() == true) { if (GUILayout.Button("打开游戏状态管理器")) { GraphWindow.OpenWindow(stateManager); } } else { if (GUILayout.Button("关闭游戏状态管理器")) { GraphWindow.CloseWindow(); } } (property.serializedObject.targetObject as UnityMonoDriver).clientGameStateManager.m_oClientStateMachine.m_dicClientStates = new Dictionary <string, ClientStateBase>(GameStateGraph.stateDics); EditorUtility.SetDirty(property.serializedObject.targetObject); GUI.enabled = true; EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); }
//called from base OnGUI, handles child property drawing protected override void DrawChildProperties(Rect sentPosition, SerializedProperty property) { //draw label Rect newPosition = DrawTopLabel(sentPosition); //draw unique id newPosition = DrawUniqueID(newPosition); //draw name field newPosition = EditorTool.DrawTextField(newPosition, name, "Name"); //draw topic question field newPosition = EditorTool.DrawTextField(newPosition, topicQuestion, "Topic Question"); //draw stages newPosition = EditorTool.DrawReorderableList(newPosition, stageList, "Stages"); }
/// <summary> /// Initializes a new instance of the <see cref="MapManager"/> class. /// </summary> public MapManager() { SelectedTool = EditorTool.Brush; ProjectManager.Instance.ProjectLoaded += ProjectLoaded; ProjectManager.Instance.ProjectClosed += ProjectClosed; ProjectManager.Instance.SettingsLoaded += SettingsLoaded; TerrainManager.Instance.TerrainSelected += TerrainSelected; TerrainManager.Instance.TerrainDeleted += TerrainDeleted; TilesetManager.Instance.SelectionChanged += SelectionChanged; TilesetManager.Instance.TilesetDeleted += TilesetDeleted; }
//------------------------------------------------------------------------- /// <summary> /// Initialize this GameEditorScreen. /// </summary> /// <returns>False if failed</returns> public override bool init() { _gameLevelMgr = new GameLevelManager(_gameContentMgr, _screenMgr.GraphicsDevice); Tool = EditorTool.TOOL_NONE; _selection = new List <GameTile>(); _grabbingSelection = false; _colorSelect = new Color(0.5f, 1.0f, 0.25f, 0.75f); _colorDeselect = Color.White; _elevating = false; _snapping = false; return(base.init()); }
public static void ExportBundleMainfestToOutput() { EditorTool.CreateDirectory(BuildConfig.InterpretedOutputPath); ExportBundleDictToOutput(); string[] list = { BuildConfig.BundleMainfestOutputPath }; uint crc = 0; bool success = BundleBuildHelper.BuildAssetBundle(list, BuildConfig.MainfestOutputPath, out crc, BundleType.TextAsset); if (!success) { Debug.LogErrorFormat("[BundleExport] BuildAssetBundle {0} Failed.", BuildConfig.BundleMainfestOutputPath); } }
protected override void DrawChildProperties(Rect position, SerializedProperty property) { Rect newPosition = DrawTopLabel(position); //draw unique id newPosition = DrawUniqueID(newPosition); //draw name newPosition = EditorTool.DrawTextField(newPosition, name, "Name"); //draw id newPosition = EditorTool.DrawIntField(newPosition, id, "Myth ID"); //draw dev description newPosition = EditorTool.DrawTextArea(newPosition, devDescription, "Dev Description"); //draw data array newPosition = EditorTool.DrawReorderableList(newPosition, reorderableList, "Stories"); }
public static void SetConfigABInfo() { AssetDatabase.Refresh(); //获取所有在ExternalAsset/Configs目录下的文件,设置ab名称 string[] files = Directory.GetFiles(Path.Combine(EditorTool.GetUnityRootFile(), "Assets/ExternalAsset/Configs"), "*.bytes"); foreach (string file in files) { string path = file.Substring(file.IndexOf("Assets/", StringComparison.Ordinal)); AssetDatabase.ImportAsset(path); AssetImporter importer = AssetImporter.GetAtPath(path); importer.assetBundleName = AssetPath.configABName; } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public static void SaveData() { if (m_texSelectData != null) { EditorTool.SaveJsonData <List <TextureImportData> >(m_texSelectData, FormatConfig.TextureImportPath); } if (m_modelSelectData != null) { EditorTool.SaveJsonData <List <ModelImportData> >(m_modelSelectData, FormatConfig.ModelImportPath); } if (m_aniSelectData != null) { EditorTool.SaveJsonData <List <AnimationImportData> >(m_aniSelectData, FormatConfig.AnimationImportPath); } }
private static void writeWindowBase(string name) { if (File.Exists(EditorTool.UnityPathToSystemPath(AutoUIPath + name))) { return; } using (var fw = new FileWriter(EditorTool.UnityPathToSystemPath(AutoUIPath + name))) { fw.Append("using Framework.UI;"); fw.Append("using Framework.Message;"); fw.Append("using UnityEngine;"); fw.Append("using UnityEngine.UI;"); fw.Append("using DG.Tweening;"); } }
public Editor() { InitializeComponent(); //Size pbLevelSize = new Size(GameEngine.SCREEN_WIDTH, GameEngine.SCREEN_HEIGHT); Size pbLevelSize = new Size(4096, 768); pb_Level.MaximumSize = (pb_Level.MinimumSize = (pb_Level.Size = pbLevelSize)); this.FormBorderStyle = FormBorderStyle.FixedSingle; currentTool = EditorTool.Insertion; ClearToolMenu(); tool_Insertion.Checked = true; // Disable object properties by default tb_Density.Enabled = false; tb_Rotation.Enabled = false; b_ApplyProperties.Enabled = false; b_Front.Enabled = false; tb_Scale.Enabled = false; tb_bound1.Enabled = false; tb_bound2.Enabled = false; cBox_StaticObject.Enabled = false; }
public Editor() { InitializeComponent(); Size pbLevelSize = new Size(Constants.WINDOW_WIDTH, Constants.WINDOW_HEIGHT - Constants.HUD_HEIGHT); pb_Level.MaximumSize = (pb_Level.MinimumSize = (pb_Level.Size = pbLevelSize)); this.FormBorderStyle = FormBorderStyle.FixedSingle; currentTool = EditorTool.Insertion; ClearToolMenu(); tool_Insertion.Checked = true; // Disable object properties by default tb_Damage.Enabled = false; tb_Rotation.Enabled = false; b_ApplyProperties.Enabled = false; b_Front.Enabled = false; tb_SLevel.Enabled = false; //Only enable this menu item if the currently selected object is a door. When we start, // we don't have a currently selected item, so disable this menu item. menu_door.Enabled = false; menu_room.Enabled = false; menu_debug.Enabled = false; }
private void tool_Selection_Click(object sender, EventArgs e) { ClearToolMenu(); tool_Selection.Checked = true; currentTool = EditorTool.Selection; }
public void tool_Insertion_Click_1( object sender, EventArgs e ) { ClearToolMenu(); tool_Insertion.Checked = true; currentTool = EditorTool.Insertion; clearLine(); }
public override void Update(GameTime gameTime) { Camera.Update(Moxy.Graphics); Map.Update(gameTime); var mouseState = Mouse.GetState (); var state = Keyboard.GetState (); if (IsFocused) { if (WasKeyPressed (state, Keys.F1)) currentTool = EditorTool.PlaceTiles; HandleCameraControls (state, gameTime); if (currentTool == EditorTool.PlaceTiles) { if (enableTileHelper) UpdateTileHelper (state); if (mouseState.LeftButton == ButtonState.Pressed) SetTileAtPoint (new Vector2 (mouseState.X, mouseState.Y), currentTileID); if (WasKeyPressed (state, Keys.NumPad1)) CurrentLayer = MapLayerType.Base; if (WasKeyPressed (state, Keys.NumPad2)) CurrentLayer = MapLayerType.Decal; if (WasKeyPressed (state, Keys.NumPad3)) CurrentLayer = MapLayerType.Collision; if (WasKeyPressed (state, Keys.F5)) ExportMapData(); } if (Moxy.CurrentKeyboard.IsKeyDown (Keys.Tab)) { IsFocused = false; Moxy.StateManager.Push ("TilePicker"); } else if (Moxy.CurrentKeyboard.IsKeyDown(Keys.LeftControl) && Moxy.LastKeyboard.IsKeyUp(Keys.LeftControl)) { IsFocused = false; Moxy.StateManager.Push("MapSerailizor"); } // String debugging Vector2 mouseVec = new Vector2 (mouseState.X, mouseState.Y); WorldAtCursor = Camera.ScreenToWorld (mouseVec); TileAtCursor = new Vector2 ((int) WorldAtCursor.X / 64, (int) WorldAtCursor.Y / 64); } oldMouse = mouseState; old = state; }
//------------------------------------------------------------------------- /// <summary> /// Initialize this GameEditorScreen. /// </summary> /// <returns>False if failed</returns> public override bool init() { _gameLevelMgr = new GameLevelManager(_gameContentMgr, _screenMgr.GraphicsDevice); Tool = EditorTool.TOOL_NONE; _selection = new List<GameTile>(); _grabbingSelection = false; _colorSelect = new Color(0.5f, 1.0f, 0.25f, 0.75f); _colorDeselect = Color.White; _elevating = false; _snapping = false; return base.init(); }
protected override bool initGUI() { _guiMgr = new GUIManager(_screenMgr); _screenMgr.Components.Add(_guiMgr); _guiMgr.Initialize(); #region Shorthand GUI item creation // Create a MenuItem Func<UIComponent, String, MenuItem> create_mi = (UIComponent parent, String text) => { MenuItem mi = new MenuItem(_screenMgr, _guiMgr); mi.Text = text; if (parent is MenuBar) (parent as MenuBar).Add(mi); else if (parent is MenuItem) (parent as MenuItem).Add(mi); return mi; }; // Create a TextButton Func<UIComponent, String, int, int, int, int, TextButton> create_btn = (UIComponent parent, String text, int w, int h, int x, int y) => { TextButton btn = new TextButton(_screenMgr, _guiMgr); btn.Text = text; btn.Width = w; btn.Height = h; btn.X = x; btn.Y = y; if (parent is Dialog) (parent as Dialog).Add(btn); else if (parent is Window) (parent as Window).Add(btn); return btn; }; // Create a Dialog Func<String, int, int, int, int, Dialog> create_dialog = (String text, int w, int h, int x, int y) => { Dialog dialog = new Dialog(_screenMgr, _guiMgr); _guiMgr.Add(dialog); dialog.TitleText = text; dialog.Width = w; dialog.Height = h; dialog.X = x; dialog.Y = y; dialog.HasCloseButton = false; int bwidth = 50; int bheight = 20; int bxoffs = 10; int byoffs = dialog.Height - 60; // Ok button TextButton btnOk = create_btn( dialog, "Ok", bwidth, bheight, bxoffs, byoffs); btnOk.Click += delegate(UIComponent sender) { dialog.DialogResult = DialogResult.OK; dialog.CloseWindow(); }; // Cancel button TextButton btnCancel = create_btn( dialog, "Cancel", bwidth, bheight, bxoffs * 2 + bwidth, byoffs); btnCancel.Click += delegate(UIComponent sender) { dialog.DialogResult = DialogResult.Cancel; dialog.CloseWindow(); }; return dialog; }; // Create a text box Func<UIComponent, String, int, int, int, TextBox> create_textbox = (UIComponent parent, String text, int w, int x, int y) => { TextBox textBox = new TextBox(_screenMgr, _guiMgr); textBox.Width = w; textBox.X = x; textBox.Y = y; Label label = new Label(_screenMgr, _guiMgr); label.Text = text; label.Width = 100; label.Height = 50; label.X = x - label.Width; label.Y = y + 5; if (parent is Dialog) { (parent as Dialog).Add(textBox); (parent as Dialog).Add(label); } return textBox; }; #endregion { // Main menu bar MenuBar menuBar = new MenuBar(_screenMgr, _guiMgr); _guiMgr.Add(menuBar); //----------------------------------------------------------------- { // File MenuItem fileButton = create_mi(menuBar, "File"); //------------------------------------------------------------- { // New MenuItem newButton = create_mi(fileButton, "New"); newButton.Click += delegate(UIComponent sender) { Dialog d = create_dialog("New", 300, 200, 100, 100); TextBox rows = create_textbox(d, "Rows", 50, 150, 10); TextBox cols = create_textbox(d, "Cols", 50, 150, 40); TextBox tile = create_textbox(d, "Tile", 100, 150, 70); d.Close += delegate(UIComponent dsender) { switch (d.DialogResult) { case DialogResult.Cancel: return; case DialogResult.OK: int numRows = Convert.ToInt32(rows.Text); int numCols = Convert.ToInt32(cols.Text); _gameLevelMgr.newLevel(numRows, numCols, tile.Text); return; } }; }; } //------------------------------------------------------------- { // Save as MenuItem saveAsButton = create_mi(fileButton, "Save as"); saveAsButton.Click += delegate(UIComponent sender) { Dialog d = create_dialog("Save as", 300, 200, 100, 100); TextBox file = create_textbox(d, "Path", 200, 100, 50); d.Close += delegate(UIComponent dsender) { switch (d.DialogResult) { case DialogResult.Cancel: return; case DialogResult.OK: _gameLevelMgr.saveLevel(LEVEL_DIRECTORY + file.Text); return; } }; }; } //------------------------------------------------------------- { // Load MenuItem loadButton = create_mi(fileButton, "Load"); loadButton.Click += delegate(UIComponent sender) { Dialog d = create_dialog("Load", 300, 200, 100, 100); TextBox file = create_textbox(d, "File", 200, 100, 50); d.Close += delegate(UIComponent dsender) { switch (d.DialogResult) { case DialogResult.Cancel: return; case DialogResult.OK: _gameLevelMgr.loadLevel("levels\\" + file.Text); return; } }; }; } //------------------------------------------------------------- { // Quit to menu MenuItem quitButton = create_mi(fileButton, "Quit to menu"); quitButton.Click += delegate(UIComponent sender) { }; } } //----------------------------------------------------------------- { // Windows MenuItem windows = create_mi(menuBar, "Windows"); Func<String, int, int, int, int, Window> create_win = (String text, int w, int h, int x, int y) => { Window win = new Window(_screenMgr, _guiMgr); _guiMgr.Add(win); win.Width = w; win.Height = h; win.X = x; win.Y = y; win.TitleText = text; return win; }; //------------------------------------------------------------- { // Tile browser MenuItem tbrowser = create_mi(windows, "Tile Browser"); tbrowser.Click += delegate(UIComponent sender) { Window tbwin = create_win("Tile Browser", 300, 500, 400, 100); //----------------------------------------------------- { // Tile buttons TextButton stoneButton = create_btn(tbwin, "Stone", 60, 30, 10, 10); stoneButton.Click += delegate(UIComponent bsender) { Drawable tdrwble = _gameContentMgr.loadDrawable("tile_stone"); foreach (GameTile tile in _selection) tile.Entity.Drawable = tdrwble; }; TextButton grassButton = create_btn(tbwin, "Grass", 60, 30, 10, 50); grassButton.Click += delegate(UIComponent bsender) { Drawable tdrwble = _gameContentMgr.loadDrawable("tile_grass"); foreach (GameTile tile in _selection) tile.Entity.Drawable = tdrwble; }; TextButton rockButton = create_btn(tbwin, "Rock", 60, 30, 10, 90); rockButton.Click += delegate(UIComponent bsender) { Drawable tdrwble = _gameContentMgr.loadDrawable("tile_rock"); foreach (GameTile tile in _selection) tile.Entity.Drawable = tdrwble; }; TextButton sandButton = create_btn(tbwin, "Sand", 60, 30, 10, 130); sandButton.Click += delegate(UIComponent bsender) { Drawable tdrwble = _gameContentMgr.loadDrawable("tile_sand"); foreach (GameTile tile in _selection) tile.Entity.Drawable = tdrwble; }; TextButton stoneSandButton = create_btn(tbwin, "S-Sand", 60, 30, 10, 170); stoneSandButton.Click += delegate(UIComponent bsender) { Drawable tdrwble = _gameContentMgr.loadDrawable("tile_stonesand"); foreach (GameTile tile in _selection) tile.Entity.Drawable = tdrwble; }; } }; } //------------------------------------------------------------- { // Character browser MenuItem chrbrowser = create_mi(windows, "Character Browser"); chrbrowser.Click += delegate(UIComponent sender) { Window chrbwin = create_win("Character Browser", 300, 500, 400, 100); }; } //------------------------------------------------------------- { // Object browser MenuItem itembrowser = create_mi(windows, "Item Browser"); itembrowser.Click += delegate(UIComponent sender) { Window ibwin = create_win("Item Browser", 300, 500, 400, 100); //----------------------------------------------------- { // Item buttons TextButton tree1btn = create_btn(ibwin, "Tree1", 60, 30, 10, 10); tree1btn.Click += delegate(UIComponent bsender) { foreach (GameTile tile in _selection) { GameObject tree = _gameLevelMgr.createGameObject<GameObject>("tree" + _gameLevelMgr.GameObjectCount, "tree1"); tile.Node.attachChildNode(tree.Node); tree.Node.translateTo(tile.Node.PositionIsometric); } }; } }; } } //----------------------------------------------------------------- { // Tool bar Window toolBar = new Window(_screenMgr, _guiMgr); _guiMgr.Add(toolBar); toolBar.HasCloseButton = false; toolBar.Width = _screenMgr.GraphicsDevice.Viewport.Width; toolBar.Height = 60; toolBar.Y = menuBar.Y + menuBar.Height; toolBar.Resizable = false; toolBar.HasFullWindowMovableArea = false; toolBar.TitleBarHeight = 4; int btncount, btnx, btny, btnw, btnh; btncount = 0; btnx = 8; btny = 4; btnw = 60; btnh = 24; //------------------------------------------------------------- { // Deselect TextButton noneButton = create_btn(toolBar, "None", btnw, btnh, ((btnx + btnw) * btncount++), btny); noneButton.Click += delegate(UIComponent sender) { Tool = EditorTool.TOOL_NONE; }; } //------------------------------------------------------------- { // Select TextButton selectButton = create_btn(toolBar, "Select", btnw, btnh, ((btnx + btnw) * btncount++), btny); selectButton.Click += delegate(UIComponent sender) { Tool = EditorTool.TOOL_SELECT; }; } //------------------------------------------------------------- { // Zero TextButton zeroButton = create_btn(toolBar, "Zero", btnw, btnh, ((btnx + btnw) * btncount++), btny); zeroButton.Click += delegate(UIComponent sender) { batchElevation(0.0f); }; } //------------------------------------------------------------- { // Elevate TextButton elevateButton = create_btn(toolBar, "Elevate", btnw, btnh, ((btnx + btnw) * btncount++), btny); elevateButton.Click += delegate(UIComponent sender) { Tool = EditorTool.TOOL_ELEVATE; }; } //------------------------------------------------------------- { // Activate TextButton activateButton = create_btn(toolBar, "Activate", btnw, btnh, ((btnx + btnw) * btncount++), btny); activateButton.Click += delegate(UIComponent sender) { batchActivate(true); }; } //------------------------------------------------------------- { // Deactivate TextButton deactivateButton = create_btn(toolBar, "Deact", btnw, btnh, ((btnx + btnw) * btncount++), btny); deactivateButton.Click += delegate(UIComponent sender) { batchActivate(false); }; } } } return base.initGUI(); }
public void SelectTool(EditorTool tool) { SelectedTool = tool; if (ToolSelected != null) ToolSelected.Invoke(this, new ToolSelectedEventArgs(SelectedTool)); }
public ToolSelectedEventArgs(EditorTool tool) { _tool = tool; }
public override void Update(GameTime gameTime) { camera.Update(Moxy.Graphics); map.Update(gameTime); var mouseState = Mouse.GetState (); var state = Keyboard.GetState (); if (WasKeyPressed (state, Keys.F1)) currentTool = EditorTool.PlaceTiles; HandleCameraControls (state, gameTime); if (currentTool == EditorTool.PlaceTiles) { int tileID = currentTileID; if (WasKeyPressed(state, Keys.Right)) tileID++;// = (int)MathHelper.Min(tileID + 1, map.Boundings.Length - 1); else if (WasKeyPressed(state, Keys.Left)) tileID--;// = Helpers.LowerClamp(tileID - 1, 0); if (tileID < 0) tileID = map.Boundings.Length + tileID; currentTileID = tileID%map.Boundings.Length; if (mouseState.LeftButton == ButtonState.Pressed) SetTileAtPoint (new Vector2 (mouseState.X, mouseState.Y), currentTileID); if (WasKeyPressed (state, Keys.NumPad1)) currentLayer = MapLayerType.Base; if (WasKeyPressed (state, Keys.NumPad2)) currentLayer = MapLayerType.Decal; if (WasKeyPressed (state, Keys.NumPad3)) currentLayer = MapLayerType.Collision; if (WasKeyPressed (state, Keys.F5)) ExportMapData (); } // String debugging Vector2 mouseVec = new Vector2(mouseState.X, mouseState.Y); WorldAtCursor = camera.ScreenToWorld (mouseVec); TileAtCursor = new Vector2 ((int)WorldAtCursor.X / 64, (int)WorldAtCursor.Y / 64); oldMouse = mouseState; old = state; }