private void Init(Rect pos) { var vec2 = new Vector2(pos.x, pos.y); Vector2 vector2 = GUIUtility.GUIToScreenPoint(vec2); UnityInternal.ShowWithModePopup(this); position = new Rect { x = vector2.x, y = vector2.y, width = pos.width, height = pos.height }; minSize = new Vector2(position.width, position.height); maxSize = new Vector2(position.width, position.height); wantsMouseMove = true; if (Application.platform == RuntimePlatform.OSXEditor) { Focus(); } }
public override void OnDisable(bool compiling) { base.OnDisable(compiling); _tsWindow.OnDisable(); _propertyWindow.OnDisable(); UnityInternal.RemoveGlobalEventHandler(HandleInput); }
public override void OnEnable() { base.OnEnable(); _tsWindow = new TilesetListWindow(this); _addWindow = new TilesetAddWindow(this); _propertyWindow = new TilesetPropertiesWindow(this); UnityInternal.AddGlobalEventHandler(HandleInput); }
private void LoadTileSets() { _tilesetList = UnityInternal.GetAssetsInProjectOfType <Tileset>(); _tilesetNames = _tilesetList.Select(t => t.Name).ToArray(); if (_tilesetList.Count > 0) { SetTileSet(_tilesetList[0].InstanceID); } UpdateTextureList(); }
private void LoadTilesets() { TilesetList = UnityInternal.GetAssetsInProjectOfType <Tileset>().ToArray(); // if no tileset set yet, set if (TilesetList.Length > 0 && !_parent.Tileset) { SetTileSet(TilesetList[0].InstanceID); } _parent.Repaint(); }
private static List <Tileset> LoadAllTilesets() { var tilesetData = UnityInternal.GetAssetsInProjectOfType <Tileset>().ToArray(); var tilesets = new List <Tileset>(); // ReSharper disable LoopCanBeConvertedToQuery foreach (var t in tilesetData) // ReSharper restore LoopCanBeConvertedToQuery { var path = AssetDatabase.GetAssetPath(t.InstanceID); var tileset = AssetDatabase.LoadAssetAtPath(path, typeof(Tileset)) as Tileset; tilesets.Add(tileset); } return(tilesets); }
private bool UpdateRequired() { var version = EditorPrefs.GetInt("TilerVersion", 0); if (version == TilerVersion) { return(false); } var tilesets = UnityInternal.GetAssetsInProjectOfType <Tileset>().ToArray(); // no tilesets to update anyway if (tilesets.Length == 0) { EditorPrefs.SetInt("TilerVersion", TilerVersion); return(false); } return(true); }
public override void OnDisable(bool compiling) { base.OnDisable(compiling); UnityInternal.RemoveGlobalEventHandler(GlobalInputHack); EditorApplication.hierarchyWindowChanged -= OnHierachyChange; if (_camera) { Object.DestroyImmediate(_camera.gameObject, true); } if (_text) { Object.DestroyImmediate(_text.gameObject, true); } /* causes internal unity error and a crash for some reason, so we just keep it in scene hidden instead * if (_light) * Object.DestroyImmediate(_light.gameObject, true);*/ _drawTileSetWindow.OnDisable(); }
public override void OnEnable() { base.OnEnable(); _lastSave = DateTime.Now; DrawTool = new PaintTool(this, null); UnityInternal.AddGlobalEventHandler(GlobalInputHack); EditorApplication.hierarchyWindowChanged += OnHierachyChange; _drawTileSetWindow = new DrawTileSetWindow(this); _brushWindow = new BrushWindow(this); RefreshMaps(); var cameraGo = GameObject.Find("TilerCamera"); if (cameraGo == null) { cameraGo = EditorUtility.CreateGameObjectWithHideFlags("TilerCamera", (HideFlags)13, new[] { typeof(Camera) }); cameraGo.AddComponent <GUILayer>(); cameraGo.AddComponent <FlareLayer>(); UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(cameraGo, "Assets/Tiler/Editor/Windows/Main/Draw/DrawWindow.cs (78,13)", "HaloLayer"); } _camera = cameraGo.GetComponent <Camera>(); _camera.enabled = false; _height = Mathf.Log(16); _camera.transform.eulerAngles = new Vector3(90, 0, 0); SetCameraHeight(); var lightGo = GameObject.Find("TilerLight"); // ReSharper disable ConvertIfStatementToNullCoalescingExpression if (lightGo == null) { // ReSharper restore ConvertIfStatementToNullCoalescingExpression lightGo = EditorUtility.CreateGameObjectWithHideFlags("TilerLight", (HideFlags)13, new[] { typeof(Light) }); } _light = lightGo.GetComponent <Light>(); _light.type = LightType.Directional; _light.intensity = 0.5f; _light.enabled = false; var textGo = GameObject.Find("TilerText"); if (textGo == null) { textGo = EditorUtility.CreateGameObjectWithHideFlags("TilerText", (HideFlags)13, new[] { typeof(GUIText) }); textGo.transform.position = new Vector3(0.5f, 1, 0); } _text = textGo.GetComponent <GUIText>(); _text.anchor = TextAnchor.UpperCenter; _text.alignment = TextAlignment.Center; //_text.font.material.color = Color.white; //_text.text = "Remember to save. Last save more than 10 minutes ago."; _text.enabled = false; }