/// <summary> /// 激活图层(取消冻结、锁定、隐藏) /// </summary> /// <param name="LayerName"></param> /// <returns></returns> public bool ActivationLayer(string LayerName = "") { try { using (Transaction tran = database.TransactionManager.StartTransaction()) { foreach (ObjectId LayerId in LayerTbl) { LayerTableRecord Layer = LayerId.GetObject(OpenMode.ForWrite) as LayerTableRecord; if (string.IsNullOrWhiteSpace(LayerName) || Layer.Name == LayerName) { Layer.IsLocked = false; Layer.IsHidden = false; Layer.IsFrozen = false; } Layer.DowngradeOpen(); } tran.Commit(); } } catch (Exception ex) { Logger.log("ActivationLayer", ex.Message); } return(false); }
override public GraphicsLayer GetGraphicsLayer() { KmlLayer kmlLayer = ArcGIS_Map.Layers[LayerId.ToString()] as KmlLayer; GraphicsLayer graphicsLayer = GetGraphicsLayer(kmlLayer as Layer); return(graphicsLayer); }
public void SetPrefab(string prefabName, LayerId layerId, bool isUsingCache = false) { _isUsingCache = isUsingCache; _effectGoName = prefabName; _effectGo = ObjectsPool.GetInstance().GetPrefabAtPool(_effectGoName); if (_effectGo == null) { GameObject protoType = ObjectsPool.GetInstance().GetProtoType(_effectGoName); if (protoType == null) { protoType = ResourceManager.GetInstance().GetPrefab("Prefab/Effects/Special", prefabName); protoType.name = _effectGoName; Transform tf = protoType.transform; tf.localPosition = new Vector3(2000, 2000, 0); UIManager.GetInstance().AddGoToLayer(protoType, layerId); ObjectsPool.GetInstance().AddProtoType(_effectGoName, protoType); } _effectGo = GameObject.Instantiate <GameObject>(protoType); UIManager.GetInstance().AddGoToLayer(_effectGo, layerId); } _effectTf = _effectGo.transform; _spRenderer = _effectTf.Find("Sprite").GetComponent <SpriteRenderer>(); // 获取sprite对象的原始尺寸 Sprite sp = _spRenderer.sprite; if (sp != null) { Vector3 size = sp.bounds.extents * 2 * sp.pixelsPerUnit; _originalWidth = size.x; _originalHeight = size.y; // 计算实际尺寸 _curWidth = _originalWidth; _curHeight = _originalHeight; } }
public void Init(string parasStr) { effectParasList = new List <float[]>(); if (parasStr == "") { return; } string[] tmpStrs0 = parasStr.Split(';'); // 基础参数 string[] tmpStrs1 = tmpStrs0[0].Split(','); atlasName = tmpStrs1[0]; spriteName = tmpStrs1[1]; blendMode = (eBlendMode)int.Parse(tmpStrs1[2]); int tmpInt = int.Parse(tmpStrs1[3]); layerId = tmpInt == -1 ? LayerId.STGNormalEffect : (LayerId)tmpInt; // 参数列表 int paraListLen = tmpStrs0.Length - 1; for (int i = 0; i < paraListLen; i++) { string[] paraStr = tmpStrs0[i + 1].Split(','); int len = paraStr.Length; float[] paraIntArr = new float[len]; for (int j = 0; j < len; j++) { paraIntArr[j] = float.Parse(paraStr[j]); } effectParasList.Add(paraIntArr); } }
public int CompareTo(CocoMakeupCanvasLayer pOther) { if (pOther == null) { return(1); } return(LayerId.CompareTo(pOther.LayerId)); }
public T CreateAnimation <T>(LayerId id) where T : AnimationBase, new() { T ani = new T(); ani.Init(id); _aniList.Add(ani); _aniCount++; return(ani); }
public T CreateAnimation <T>(GameObject aniParent, string rendererName, LayerId id) where T : AnimationBase, new() { T ani = new T(); ani.Init(aniParent, rendererName, id); _aniList.Add(ani); _aniCount++; return(ani); }
/// <summary> /// 设置特殊的SpriteEffect /// <para>spriteEffect</para> /// <para>预制体名称</para> /// <para>layerId 层级</para> /// <para>是否缓存</para> /// </summary> /// <param name="luaState"></param> /// <returns></returns> public static int SpriteEffectSetPefab(ILuaState luaState) { STGSpriteEffect effect = luaState.ToUserData(-4) as STGSpriteEffect; string prefabName = luaState.ToString(-3); LayerId layerId = (LayerId)luaState.ToInteger(-2); bool cached = luaState.ToBoolean(-1); effect.SetPrefab(prefabName, layerId, cached); return(0); }
public virtual void Init(GameObject aniParent, string rendererName, LayerId id) { _aniParent = aniParent; _trans = _aniParent.transform; _aniTf = _trans.Find(rendererName); _aniObject = _aniTf.gameObject; _renderer = _aniTf.GetComponent <SpriteRenderer>(); UIManager.GetInstance().AddGoToLayer(_aniParent, id); _curColor = DefaultColor; _curScale = DefaultScale; _isDefaultPrefab = false; }
public static int SetSTGObjectProps(ILuaState luaState) { STGSpriteEffect effect = luaState.ToUserData(-6) as STGSpriteEffect; string atlasName = luaState.ToString(-5); string spriteName = luaState.ToString(-4); eBlendMode blendMode = (eBlendMode)luaState.ToInteger(-3); LayerId layerId = (LayerId)luaState.ToInteger(-2); bool cached = luaState.ToBoolean(-1); effect.SetSprite(atlasName, spriteName, blendMode, layerId, cached); return(0); }
public int CompareTo(Picture other) { if (other == null) { throw new ArgumentNullException("other"); } if (LayerId != other.LayerId) { return(LayerId.CompareTo(other.LayerId)); } return(Index.CompareTo(other.Index)); }
public IDataBuffer TryGetBuffer(Int2 chunkCoord, LayerId layerId) { ChunkData chunk; if (TryGetChunkData(chunkCoord, out chunk)) { return(chunk.GetBuffer(layerId)); } else { return(null); } }
override public void CloseLayer() { KmlLayer shapeLayer = ArcGIS_Map.Layers[LayerId.ToString()] as KmlLayer; if (shapeLayer != null) { ArcGIS_Map.Layers.Remove(shapeLayer); if (LegendStackPanel != null) { LegendStackPanel.Children.Clear(); } } }
/// <summary> /// 根据属性创建指定的SpriteEffect /// <para>atlasName</para> /// <para>spriteName</para> /// <para>cached 是否缓存</para> /// <para>layerId 层级</para> /// <para>在层级中的顺序</para> /// </summary> /// <param name="luaState"></param> /// <returns></returns> public static int CreateSpriteEffectWithProps(ILuaState luaState) { string atlasName = luaState.ToString(-6); string spriteName = luaState.ToString(-5); eBlendMode blendMode = (eBlendMode)luaState.ToInteger(-4); LayerId layerId = (LayerId)luaState.ToInteger(-3); bool cached = luaState.ToBoolean(-2); int orderInLayer = luaState.ToInteger(-1); STGSpriteEffect effect = EffectsManager.GetInstance().CreateEffectByType(EffectType.SpriteEffect) as STGSpriteEffect; effect.SetSprite(atlasName, spriteName, blendMode, layerId, cached); effect.SetOrderInLayer(orderInLayer); luaState.PushLightUserData(effect); return(1); }
public void AddGoToLayer(GameObject go, LayerId layerId) { if (go != null) { Transform layerTf; if (_layersMap.TryGetValue(layerId, out layerTf)) { go.transform.SetParent(layerTf, false); //go.transform.localScale = Vector3.one; } else { Logger.Log("Get layer fail,layerId = " + layerId); } } }
public object GetCellValue(Int2 gridCoord, LayerId layerId) { Int2 chunkCoord = GetChunkCoord(gridCoord, chunkWidth, chunkHeight); ChunkData chunk; if (TryGetChunkData(chunkCoord, out chunk)) { int index = GetCellIndex(gridCoord, chunkWidth, chunkHeight); IDataBuffer buffer = chunk.GetBuffer(layerId); return(buffer.GetValue(index)); } else { return(0); } }
///// <summary> ///// Calculates Axis-Aligned Bounding Box in world space for the specified chunk. ///// </summary> //public Bounds CalculateChunkAABB(Int2 chunkCoord) { // Vector3 pos = transform.position; // Matrix4x4 m = transform.localToWorldMatrix; // Vector2 p1 = m * new Vector2(chunkCoord.x * chunkWidth, chunkCoord.y * chunkHeight); // Vector2 p2 = m * new Vector2(chunkCoord.x * chunkWidth, (chunkCoord.y + 1) * chunkHeight); // Vector2 p3 = m * new Vector2((chunkCoord.x + 1) * chunkWidth, (chunkCoord.y + 1) * chunkHeight); // Vector2 p4 = m * new Vector2((chunkCoord.x + 1) * chunkWidth, chunkCoord.y * chunkHeight); // float[] x = { p1.x, p2.x, p3.x, p4.x }; // float[] y = { p1.y, p2.y, p3.y, p4.y }; // float minX = Mathf.Min(x); // float minY = Mathf.Min(y); // float maxX = Mathf.Max(x); // float maxY = Mathf.Max(y); // Vector3 size = new Vector3(maxX - minX, maxY - minY, 10); // Vector3 center = new Vector3(minX + pos.x, minY + pos.y) + 0.5f * size; // return new Bounds(center, size); //} public uint GetUnsignedInt(Int2 gridCoord, LayerId layerId) { Int2 chunkCoord = GetChunkCoord(gridCoord, chunkWidth, chunkHeight); ChunkData chunk; if (TryGetChunkData(chunkCoord, out chunk)) { int index = GetCellIndex(gridCoord, chunkWidth, chunkHeight); BufferUnsignedInt32 buffer = (BufferUnsignedInt32)chunk.GetBuffer(layerId); return(buffer.GetValue(index)); } else { return(0); } }
void graphicsLayer_UpdateCompleted(object sender, EventArgs e) { FeatureLayer graphicsLayer = ArcGIS_Map.Layers[LayerId.ToString()] as FeatureLayer; _flagUpdateToGraphicsLayerFailed = false; if (graphicsLayer != null) { if (graphicsLayer.Graphics.Count > 0) { if (FeatureLoaded != null) { FeatureLoaded(graphicsLayer.Url, graphicsLayer.Graphics[0].Attributes); } } } ArcGIS_Map.Cursor = Cursors.Arrow; }
public virtual void Init(LayerId id) { _aniParent = ObjectsPool.GetInstance().GetPrefabAtPool("AniParent"); if (_aniParent != null) { _aniParent.SetActive(true); } else { _aniParent = ResourceManager.GetInstance().GetPrefab("Animation", "AniParent"); } _trans = _aniParent.transform; _aniTf = _trans.Find("Animation"); _aniObject = _aniTf.gameObject; _renderer = _aniTf.GetComponent <SpriteRenderer>(); UIManager.GetInstance().AddGoToLayer(_aniParent, id); _curColor = DefaultColor; _curScale = DefaultScale; _isDefaultPrefab = true; }
public int CompareTo(Macroblock other) { if (other == null) { throw new ArgumentNullException("other"); } if (LayerId != other.LayerId) { return(LayerId.CompareTo(other.LayerId)); } if (PictureId != other.PictureId) { return(PictureId.CompareTo(other.PictureId)); } if (SliceId != other.SliceId) { return(SliceId.CompareTo(other.SliceId)); } return(Mb.CompareTo(other.Mb)); }
public void Init() { _uiRoot = GameObject.Find("UIRoot"); _uiRootTf = _uiRoot.GetComponent <RectTransform>(); Rect rootRect = _uiRootTf.rect; _uiRootWidth = rootRect.width; _uiRootHeight = rootRect.height; _uiDefaultPos = new Vector2(_uiRootWidth / 2, _uiRootHeight / 2); _stgLayerTf = _uiRoot.transform.Find("GameLayer"); _uiCamera = _uiRoot.transform.Find("UICamera").GetComponent <Camera>(); // UIRoot层级 _layersMap = new Dictionary <LayerId, Transform>(); int layerCount = (int)LayerId.LayerCount; for (int i = 1; i < layerCount; i++) { LayerId tmpLayerId = (LayerId)i; GameObject layerGo = new GameObject("Layer_" + tmpLayerId.ToString()); RectTransform layerTf = layerGo.AddComponent <RectTransform>(); layerTf.SetParent(_uiRootTf, false); layerTf.localPosition = new Vector3(0, 0, (layerCount - i) * 250); layerTf.anchorMin = Vector2.zero; layerTf.anchorMax = Vector2.one; layerTf.sizeDelta = Vector2.zero; // 添加到layerMap中 _layersMap.Add(tmpLayerId, layerTf); } if (_viewsMap == null) { _viewsMap = new Dictionary <int, ViewBase>(); } if (_viewUpdateList == null) { _viewUpdateList = new List <ViewBase>(); } _viewUpdateCount = 0; InitFocus(); DoScreenAdaption(); }
public void SetCellValue <T>(Int2 gridCoord, LayerId layerId, T value) { Int2 chunkCoord = GetChunkCoord(gridCoord, chunkWidth, chunkHeight); ChunkData chunk; if (TryGetChunkData(chunkCoord, out chunk)) { int index = GetCellIndex(gridCoord, chunkWidth, chunkHeight); IDataBuffer buffer = chunk.GetBuffer(layerId); // set the new cell value buffer.SetValue(index, value); // mark the chunk and buffer as modified, so that other systems will be aware of the change. chunk.MarkModified(layerId.id, Time.frameCount); } else { // The chunk did not exist, don't set cell value. } }
private void btnProjectAreaPrice_Click(object sender, EventArgs e) { try { List <SqlParameter> param = new List <SqlParameter>(); param.Add(new SqlParameter("MapId", MapId)); param.Add(new SqlParameter("LayerId", LayerId)); param.Add(new SqlParameter("ObjectId", ObjectId)); DataTable table = SqlHelper.Select(SqlHelper.GetSql("SelectMaxMinProjectYear"), param); int startyear = DateTime.Now.Year; int endyear = DateTime.Now.Year; if (table != null && table.Rows.Count > 0) { int.TryParse(table.Rows[0]["MinYear"].ToString(), out startyear); int.TryParse(table.Rows[0]["MaxYear"].ToString(), out endyear); } ProjectAreaPriceReportConditionForm form = new ProjectAreaPriceReportConditionForm(); form.StartYear = startyear; form.EndYear = endyear; if (form.ShowDialog() == DialogResult.OK) { string sql = SqlHelper.GetSql("SelectProjectAreaPrice"); sql = sql.Replace("@StartYear", form.StartYear.ToString()); sql = sql.Replace("@EndYear", form.EndYear.ToString()); sql = sql.Replace("@MapId", MapId.ToString()); sql = sql.Replace("@LayerId", LayerId.ToString()); sql = sql.Replace("@ObjectId", ObjectId.ToString()); ReportForm report = new ReportForm(); report.SQL = sql; report.XAxisColumnName = "估价基准日"; report.Title = "宗地地价走势图"; report.GraphType = ReportForm.ReportGraphType.Line; report.Show(); } } catch (Exception ex) { Common.ShowError(ex); } }
private void MountSettingsFile(Lifetime lifetime, string pluginId, FileSystemPath path, UserFriendlySettingsLayer.Identity hostId, IThreading threading, IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior, UserInjectedSettingsLayers userInjectedSettingsLayers) { var id = string.Format("extension::{0}-{1}", pluginId, path.Name); var persistentId = new LayerId(id); var pathAsProperty = new Property <FileSystemPath>(lifetime, "InjectedFileStoragePath", path); var serialization = CreateXmlFileSettingsStorage(lifetime, threading, filetracker, behavior, id, pathAsProperty); var descriptor = new LayerDescriptor(lifetime, hostId, persistentId, serialization.Storage, MountPath.Default, () => { }); descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DisplayName, string.Format("{0} » {1}", pluginId, path.NameWithoutExtension)); descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.Origin, string.Format("Published by plugin: {0}", pluginId)); descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DiskFilePath, path); descriptor.InitialMetadata.Set(IsNonUserEditable, true); userInjectedSettingsLayers.RegisterUserInjectedLayer(lifetime, descriptor); }
override public object[] Load(string boundrySourceLocation) { if (!string.IsNullOrEmpty(boundrySourceLocation)) { FileInfo shapeFile = new FileInfo(boundrySourceLocation); string directoryName = System.IO.Path.GetDirectoryName(boundrySourceLocation); string dbfFilename = System.IO.Path.GetFileName(boundrySourceLocation).ToLowerInvariant().Replace(".shp", ".dbf"); string dbfFullPath = System.IO.Path.Combine(directoryName, dbfFilename); FileInfo dbfFile = new FileInfo(dbfFullPath); if (!dbfFile.Exists) { System.Windows.MessageBox.Show("Associated DBF file not found"); return(null); } ShapeFileReader.ShapeFile shapeFileReader = new ShapeFileReader.ShapeFile(); if (shapeFile != null && dbfFile != null) { try { shapeFileReader.Read(shapeFile, dbfFile); } catch (NotSupportedException e) { System.Windows.MessageBox.Show(e.Message); return(null); } catch { System.Windows.MessageBox.Show(DashboardSharedStrings.DASHBOARD_MAP_N_POLYGONS_EXCEEDED); return(null); } } else { System.Windows.MessageBox.Show("Please select a SP and a DBF file to proceed."); return(null); } GraphicsLayer graphicsLayer = GetGraphicsLayer(); if (graphicsLayer == null) { graphicsLayer = new GraphicsLayer(); graphicsLayer.ID = LayerId.ToString(); ArcGIS_Map.Layers.Add(graphicsLayer); int recCount = shapeFileReader.Records.Count; int rgbFactor = 255 / recCount; int counter = 0; foreach (ShapeFileReader.ShapeFileRecord record in shapeFileReader.Records) { Graphic graphic = record.ToGraphic(); if (graphic != null) { graphic.Symbol = GetFillSymbol(new SolidColorBrush(Color.FromArgb(240, 255, 255, 255))); graphicsLayer.Graphics.Add(graphic); } counter += rgbFactor; } } if (graphicsLayer.FullExtent == null) { Envelope shapeFileExtent = shapeFileReader.GetExtent(); if (shapeFileExtent.SpatialReference == null) { ArcGIS_Map.Extent = shapeFileExtent; } else { if (shapeFileExtent.SpatialReference.WKID == 4326) { ArcGIS_Map.Extent = new Envelope( ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(shapeFileExtent.XMin, shapeFileExtent.YMin)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(shapeFileExtent.XMax, shapeFileExtent.YMax))); } } } else { ArcGIS_Map.Extent = graphicsLayer.FullExtent; } graphicsLayer.RenderingMode = GraphicsLayerRenderingMode.Static; return(new object[] { boundrySourceLocation, graphicsLayer.Graphics[0].Attributes }); } else { return(null); } }
override public GraphicsLayer GetGraphicsLayer() { GraphicsLayer graphicsLayer = ArcGIS_Map.Layers[LayerId.ToString()] as GraphicsLayer; return(graphicsLayer); }
sealed override public object[] Load(string boundrySourceLocation) { if (!string.IsNullOrEmpty(boundrySourceLocation)) { _kmlURL = boundrySourceLocation; KmlLayer shapeLayer = ArcGIS_Map.Layers[LayerId.ToString()] as KmlLayer; if (shapeLayer != null) { ArcGIS_Map.Layers.Remove(shapeLayer); } shapeLayer = new KmlLayer(); shapeLayer.ID = LayerId.ToString(); shapeLayer.Url = new Uri(boundrySourceLocation); shapeLayer.Initialized += new EventHandler <EventArgs>(shapeLayer_Initialized); ArcGIS_Map.Layers.Add(shapeLayer); ArcGIS_Map.Extent = shapeLayer.FullExtent; //KmlLayer shapeLayer = ArcGIS_Map.Layers[_layerId.ToString()] as KmlLayer; GraphicsLayer graphicsLayer = GetGraphicsLayer(shapeLayer); if (graphicsLayer != null) { IDictionary <string, object> coreAttributes = graphicsLayer.Graphics[0].Attributes; Dictionary <string, object> allAttributes = new Dictionary <string, object>(); foreach (KeyValuePair <string, object> attr in coreAttributes) { allAttributes.Add(attr.Key, attr.Value); } AddSchemaDataAttributes(_kmlURL, graphicsLayer.Graphics); if (graphicsLayer.Graphics[0].Attributes.ContainsKey("extendedData")) { List <KmlExtendedData> eds = (List <KmlExtendedData>)graphicsLayer.Graphics[0].Attributes["extendedData"]; foreach (KmlExtendedData ed in eds) { allAttributes.Add(ed.Name, ed.Value); } } if (FeatureLoaded != null) { FeatureLoaded(_kmlURL, allAttributes); } double xmin = graphicsLayer.Graphics[0].Geometry.Extent.XMin; double xmax = graphicsLayer.Graphics[0].Geometry.Extent.XMax; double ymin = graphicsLayer.Graphics[0].Geometry.Extent.YMin; double ymax = graphicsLayer.Graphics[0].Geometry.Extent.YMax; foreach (Graphic g in graphicsLayer.Graphics) { if (g.Geometry.Extent.XMin < xmin) { xmin = g.Geometry.Extent.XMin; } if (g.Geometry.Extent.YMin < ymin) { ymin = g.Geometry.Extent.YMin; } if (g.Geometry.Extent.XMax > xmax) { xmax = g.Geometry.Extent.XMax; } if (g.Geometry.Extent.YMax > ymax) { ymax = g.Geometry.Extent.YMax; } } ArcGIS_Map.Extent = new Envelope( ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(xmin - 0.5, ymax + 0.5)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(xmax + 0.5, ymin - 0.5)) ); } if (graphicsLayer == null) { return(new object[] { boundrySourceLocation, null }); } else { return(new object[] { boundrySourceLocation, graphicsLayer.Graphics[0].Attributes }); } } else { return(null); } }
public void SetSprite(string atlasName, string spName, eBlendMode blendMode = eBlendMode.Normal, LayerId layerId = LayerId.STGNormalEffect, bool isUsingCache = false) { _isUsingCache = isUsingCache; // 不使用缓存,直接创建 if (!isUsingCache) { _effectGo = ResourceManager.GetInstance().GetPrefab("Prefab/Effects", "SpriteEffect"); _effectTf = _effectGo.transform; _text = _effectTf.Find("Text").GetComponent <Text>(); if (blendMode != eBlendMode.Normal) { _text.material = ResourceManager.GetInstance().GetSpriteMatByBlendMode(blendMode); } //_text.sprite = ResourceManager.GetInstance().GetSprite(atlasName, spName); UIManager.GetInstance().AddGoToLayer(_effectGo, layerId); } else { _effectGoName = "SpriteEffect_" + atlasName + "_" + spName + "_" + blendMode; _effectGo = ObjectsPool.GetInstance().GetPrefabAtPool(_effectGoName); if (_effectGo == null) { GameObject protoType = ObjectsPool.GetInstance().GetProtoType(_effectGoName); if (protoType == null) { protoType = ResourceManager.GetInstance().GetPrefab("Prefab/Effects", "SpriteEffect"); protoType.name = _effectGoName; Transform tf = protoType.transform; tf.localPosition = new Vector3(2000, 2000, 0); SpriteRenderer sr = tf.Find("Sprite").GetComponent <SpriteRenderer>(); if (blendMode != eBlendMode.Normal) { sr.material = ResourceManager.GetInstance().GetSpriteMatByBlendMode(blendMode); } sr.sprite = ResourceManager.GetInstance().GetSprite(atlasName, spName); UIManager.GetInstance().AddGoToLayer(protoType, LayerId.STGNormalEffect); ObjectsPool.GetInstance().AddProtoType(_effectGoName, protoType); } _effectGo = GameObject.Instantiate <GameObject>(protoType); UIManager.GetInstance().AddGoToLayer(_effectGo, layerId); } _effectTf = _effectGo.transform; _text = _effectTf.Find("Text").GetComponent <Text>(); } }
/// <summary> /// 设置特效所在的层级 /// </summary> /// <param name="layerId"></param> public void SetLayer(LayerId layerId) { UIManager.GetInstance().AddGoToLayer(_effectGo, layerId); }
public void SetSprite(string atlasName, string spName, eBlendMode blendMode = eBlendMode.Normal, LayerId layerId = LayerId.STGNormalEffect, bool isUsingCache = false) { _isUsingCache = isUsingCache; // 不使用缓存,直接创建 if (!isUsingCache) { _effectGo = ResourceManager.GetInstance().GetPrefab("Prefab/Effects", "SpriteEffect"); _effectTf = _effectGo.transform; _spRenderer = _effectTf.Find("Sprite").GetComponent <SpriteRenderer>(); if (blendMode != eBlendMode.Normal) { _spRenderer.material = ResourceManager.GetInstance().GetSpriteMatByBlendMode(blendMode); } _spRenderer.sprite = ResourceManager.GetInstance().GetSprite(atlasName, spName); UIManager.GetInstance().AddGoToLayer(_effectGo, layerId); } else { _effectGoName = "SpriteEffect_" + atlasName + "_" + spName + "_" + blendMode; _effectGo = ObjectsPool.GetInstance().GetPrefabAtPool(_effectGoName); if (_effectGo == null) { GameObject protoType = ObjectsPool.GetInstance().GetProtoType(_effectGoName); if (protoType == null) { protoType = ResourceManager.GetInstance().GetPrefab("Prefab/Effects", "SpriteEffect"); protoType.name = _effectGoName; Transform tf = protoType.transform; tf.localPosition = new Vector3(2000, 2000, 0); SpriteRenderer sr = tf.Find("Sprite").GetComponent <SpriteRenderer>(); if (blendMode != eBlendMode.Normal) { sr.material = ResourceManager.GetInstance().GetSpriteMatByBlendMode(blendMode); } sr.sprite = ResourceManager.GetInstance().GetSprite(atlasName, spName); UIManager.GetInstance().AddGoToLayer(protoType, LayerId.STGNormalEffect); ObjectsPool.GetInstance().AddProtoType(_effectGoName, protoType); } _effectGo = GameObject.Instantiate <GameObject>(protoType); UIManager.GetInstance().AddGoToLayer(_effectGo, layerId); } _effectTf = _effectGo.transform; _spRenderer = _effectTf.Find("Sprite").GetComponent <SpriteRenderer>(); } // 获取sprite对象的原始尺寸 Sprite sp = _spRenderer.sprite; if (sp != null) { Vector3 size = sp.bounds.extents * 2 * sp.pixelsPerUnit; _originalWidth = size.x; _originalHeight = size.y; // 计算实际尺寸 _curWidth = _originalWidth; _curHeight = _originalHeight; } else { _originalWidth = 0; _originalHeight = 0; // 计算实际尺寸 _curWidth = 0; _curHeight = 0; } }
private void MountSettingsFile(Lifetime lifetime, string pluginId, FileSystemPath path, UserFriendlySettingsLayer.Identity hostId, IThreading threading, IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior, UserInjectedSettingsLayers userInjectedSettingsLayers) { var id = string.Format("extension::{0}-{1}", pluginId, path.Name); var persistentId = new LayerId(id); var pathAsProperty = new Property<FileSystemPath>(lifetime, "InjectedFileStoragePath", path); var serialization = CreateXmlFileSettingsStorage(lifetime, threading, filetracker, behavior, id, pathAsProperty); var descriptor = new LayerDescriptor(lifetime, hostId, persistentId, serialization.Storage, MountPath.Default, () => { }); descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DisplayName, string.Format("{0} » {1}", pluginId, path.NameWithoutExtension)); descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.Origin, string.Format("Published by plugin: {0}", pluginId)); descriptor.InitialMetadata.Set(UserFriendlySettingsLayers.DiskFilePath, path); descriptor.InitialMetadata.Set(IsNonUserEditable, true); userInjectedSettingsLayers.RegisterUserInjectedLayer(lifetime, descriptor); }