当前位置: 首页>>代码示例>>C#>>正文


C# ConvertOperation.MarkObjectHandled方法代码示例

本文整理汇总了C#中ConvertOperation.MarkObjectHandled方法的典型用法代码示例。如果您正苦于以下问题:C# ConvertOperation.MarkObjectHandled方法的具体用法?C# ConvertOperation.MarkObjectHandled怎么用?C# ConvertOperation.MarkObjectHandled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConvertOperation的用法示例。


在下文中一共展示了ConvertOperation.MarkObjectHandled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

		public override bool Convert(ConvertOperation convert)
		{
			List<object> results = new List<object>();
			List<Font> availData = convert.Perform<Font>().ToList();

			// Generate objects
			foreach (Font font in availData)
			{
				if (convert.IsObjectHandled(font)) continue;

				GameObject gameobj = convert.Result.OfType<GameObject>().FirstOrDefault();
				TextRenderer renderer = convert.Result.OfType<TextRenderer>().FirstOrDefault();
				if (renderer == null && gameobj != null) renderer = gameobj.GetComponent<TextRenderer>();
				if (renderer == null) renderer = new TextRenderer();
				convert.SuggestResultName(renderer, font.Name);
					
				if (!renderer.Text.Fonts.Contains(font))
				{
					var fonts = renderer.Text.Fonts.ToList();
					if (fonts[0] == Font.GenericMonospace10) fonts.RemoveAt(0);
					fonts.Add(font);
					renderer.Text.Fonts = fonts.ToArray();
					renderer.Text.ApplySource();
				}

				results.Add(renderer);
				convert.MarkObjectHandled(font);
			}

			convert.AddResult(results);
			return false;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:32,代码来源:ComponentFromFont.cs

示例2: Convert

        public override bool Convert(ConvertOperation convert)
        {
            bool finishConvertOp = false;
            List<Pixmap> availData = convert.Perform<Pixmap>().ToList();

            // Generate objects
            foreach (Pixmap baseRes in availData)
            {
                if (convert.IsObjectHandled(baseRes)) continue;

                // Find target Resource matching the source - or create one.
                Texture targetRes = this.FindMatch(baseRes);
                if (targetRes == null && convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
                {
                    string texPath = PathHelper.GetFreePath(baseRes.FullName, Resource.GetFileExtByType<Texture>());
                    targetRes = new Texture(baseRes);
                    targetRes.Save(texPath);
                }

                if (targetRes == null) continue;
                convert.AddResult(targetRes);
                finishConvertOp = true;
                convert.MarkObjectHandled(baseRes);
            }

            return finishConvertOp;
        }
开发者ID:ninja2003,项目名称:duality,代码行数:27,代码来源:TextureFromPixmap.cs

示例3: Convert

        public override bool Convert(ConvertOperation convert)
        {
            bool finishConvertOp = false;
            List<Texture> availData = convert.Perform<Texture>().ToList();

            // Generate objects
            foreach (Texture baseRes in availData)
            {
                if (convert.IsObjectHandled(baseRes)) continue;

                // Find target Resource matching the source - or create one.
                Material targetRes =
                    this.FindMatchingResources<Texture,Material>(baseRes, IsMatch)
                    .FirstOrDefault();
                if (targetRes == null && convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
                {
                    string resPath = PathHelper.GetFreePath(baseRes.FullName, Resource.GetFileExtByType<Material>());
                    targetRes = new Material(DrawTechnique.Mask, ColorRgba.White, baseRes);
                    targetRes.Save(resPath);
                }

                if (targetRes == null) continue;
                convert.AddResult(targetRes);
                finishConvertOp = true;
                convert.MarkObjectHandled(baseRes);
            }

            return finishConvertOp;
        }
开发者ID:SirePi,项目名称:duality,代码行数:29,代码来源:MaterialFromTexture.cs

示例4: Convert

		public override bool Convert(ConvertOperation convert)
		{
			bool finishConvertOp = false;

			if (convert.Data.ContainsGameObjectRefs())
			{
				GameObject[] draggedObjArray = convert.Data.GetGameObjectRefs();

				// Filter out GameObjects that are children of others
				draggedObjArray = draggedObjArray.Where(o => !draggedObjArray.Any(o2 => o.IsChildOf(o2))).ToArray();

				// Generate Prefabs
				foreach (GameObject draggedObj in draggedObjArray)
				{
					if (convert.IsObjectHandled(draggedObj)) continue;

					// Create Prefab
					Prefab prefab = new Prefab(draggedObj);

					// Add a name hint that may be used as indicator to select a Resource name later
					prefab.AssetInfo = new AssetInfo();
					prefab.AssetInfo.NameHint = draggedObj.Name;

					// Mark GameObject as handled
					convert.MarkObjectHandled(draggedObj);						
					convert.AddResult(prefab);
					finishConvertOp = true;
				}
			}

			return finishConvertOp;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:32,代码来源:PrefabFromGameObject.cs

示例5: Convert

        public override bool Convert(ConvertOperation convert)
        {
            bool finishConvertOp = false;
            List<Pixmap> availData = convert.Perform<Pixmap>().ToList();

            // Generate objects
            foreach (Pixmap baseRes in availData)
            {
                if (convert.IsObjectHandled(baseRes)) continue;

                // Find target Resource matching the source - or create one.
                Texture targetRes = this.FindMatch(baseRes);
                if (targetRes == null && convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
                {
                    targetRes = Texture.CreateFromPixmap(baseRes).Res;
                }

                if (targetRes == null) continue;
                convert.AddResult(targetRes);
                finishConvertOp = true;
                convert.MarkObjectHandled(baseRes);
            }

            return finishConvertOp;
        }
开发者ID:sinithwar,项目名称:duality,代码行数:25,代码来源:TextureFromPixmap.cs

示例6: Convert

		public override bool Convert(ConvertOperation convert)
		{
			List<object> results = new List<object>();
			List<Material> availData = convert.Perform<Material>().ToList();

			// Generate objects
			foreach (Material mat in availData)
			{
				if (convert.IsObjectHandled(mat)) continue;

				DrawTechnique tech = mat.Technique.Res;
				LightingTechnique lightTech = tech as LightingTechnique;
				if (tech == null) continue;

				bool isDynamicLighting = lightTech != null ||
					tech.PreferredVertexFormat == VertexC1P3T2A4.Declaration ||
					tech.PreferredVertexFormat == VertexC1P3T4A4A1.Declaration;
				if (!isDynamicLighting) continue;

				Texture mainTex = mat.MainTexture.Res;
				Pixmap basePixmap = (mainTex != null) ? mainTex.BasePixmap.Res : null;
				GameObject gameobj = convert.Result.OfType<GameObject>().FirstOrDefault();

				if (mainTex == null || basePixmap == null || basePixmap.AnimFrames == 0)
				{
					LightingSpriteRenderer sprite = convert.Result.OfType<LightingSpriteRenderer>().FirstOrDefault();
					if (sprite == null && gameobj != null) sprite = gameobj.GetComponent<LightingSpriteRenderer>();
					if (sprite == null) sprite = new LightingSpriteRenderer();
					sprite.SharedMaterial = mat;
					if (mainTex != null) sprite.Rect = Rect.Align(Alignment.Center, 0.0f, 0.0f, mainTex.PixelWidth, mainTex.PixelHeight);
					convert.SuggestResultName(sprite, mat.Name);
					results.Add(sprite);
				}
				else
				{
					LightingAnimSpriteRenderer sprite = convert.Result.OfType<LightingAnimSpriteRenderer>().FirstOrDefault();
					if (sprite == null && gameobj != null) sprite = gameobj.GetComponent<LightingAnimSpriteRenderer>();
					if (sprite == null) sprite = new LightingAnimSpriteRenderer();
					sprite.SharedMaterial = mat;
					sprite.Rect = Rect.Align(Alignment.Center, 
						0.0f, 
						0.0f, 
						(mainTex.PixelWidth / basePixmap.AnimCols) - basePixmap.AnimFrameBorder * 2, 
						(mainTex.PixelHeight / basePixmap.AnimRows) - basePixmap.AnimFrameBorder * 2);
					sprite.AnimDuration = 5.0f;
					sprite.AnimFrameCount = basePixmap.AnimFrames;
					convert.SuggestResultName(sprite, mat.Name);
					results.Add(sprite);
				}
				
				convert.MarkObjectHandled(mat);
			}

			convert.AddResult(results);
			return false;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:56,代码来源:LightingRendererFromMaterial.cs

示例7: Convert

		public override bool Convert(ConvertOperation convert)
		{
			List<Component> availData = convert.Perform<Component>().ToList();
			availData.Sort((Component a, Component b) => a.RequiresComponent(b.GetType()) ? 1 : 0);

			// Generate objects
			foreach (Component cmp in availData)
			{
				if (convert.IsObjectHandled(cmp)) continue;
				Type cmpType = cmp.GetType();

				// Create or retrieve GameObject
				GameObject gameObj = null;
				{
					// First try to get one from the resultset that has an open slot for this kind of Component
					if (gameObj == null)
						gameObj = convert.Result.OfType<GameObject>().FirstOrDefault(g => g.GetComponent(cmpType) == null);
					// Still none? Create a new GameObject
					if (gameObj == null)
					{
						gameObj = new GameObject();

						// Come up with a suitable name
						string nameSuggestion = null;
						{
							// Be open for suggestions
							if (nameSuggestion == null)
								nameSuggestion = convert.TakeSuggestedResultName(cmp);
							// Use a standard name
							if (nameSuggestion == null)
								nameSuggestion = cmpType.Name;
						}

						gameObj.Name = nameSuggestion;
					}
				}

				// Make sure all requirements are met
				foreach (Type t in Component.GetRequiredComponents(cmpType))
					gameObj.AddComponent(t);

				// Make sure no other Component of this Type is already added
				gameObj.RemoveComponent(cmpType);

				// Add Component
				gameObj.AddComponent(cmp.GameObj == null ? cmp : cmp.Clone());

				convert.AddResult(gameObj);
				convert.MarkObjectHandled(cmp);
			}

			return false;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:53,代码来源:GameObjFromComponents.cs

示例8: Convert

        public override bool Convert(ConvertOperation convert)
        {
            // If we already have a renderer in the result set, consider generating
            // another one to be not the right course of action.
            if (convert.Result.OfType<ICmpRenderer>().Any())
                return false;

            List<object> results = new List<object>();
            List<Material> availData = convert.Perform<Material>().ToList();

            // Generate objects
            foreach (Material mat in availData)
            {
                if (convert.IsObjectHandled(mat)) continue;
                Texture mainTex = mat.MainTexture.Res;
                Pixmap basePixmap = (mainTex != null) ? mainTex.BasePixmap.Res : null;
                GameObject gameobj = convert.Result.OfType<GameObject>().FirstOrDefault();

                if (mainTex == null || basePixmap == null || basePixmap.AnimFrames == 0)
                {
                    SpriteRenderer sprite = convert.Result.OfType<SpriteRenderer>().FirstOrDefault();
                    if (sprite == null && gameobj != null) sprite = gameobj.GetComponent<SpriteRenderer>();
                    if (sprite == null) sprite = new SpriteRenderer();
                    sprite.SharedMaterial = mat;
                    if (mainTex != null) sprite.Rect = Rect.Align(Alignment.Center, 0.0f, 0.0f, mainTex.PixelWidth, mainTex.PixelHeight);
                    convert.SuggestResultName(sprite, mat.Name);
                    results.Add(sprite);
                }
                else
                {
                    AnimSpriteRenderer sprite = convert.Result.OfType<AnimSpriteRenderer>().FirstOrDefault();
                    if (sprite == null && gameobj != null) sprite = gameobj.GetComponent<AnimSpriteRenderer>();
                    if (sprite == null) sprite = new AnimSpriteRenderer();
                    sprite.SharedMaterial = mat;
                    sprite.Rect = Rect.Align(Alignment.Center,
                        0.0f,
                        0.0f,
                        (mainTex.PixelWidth / basePixmap.AnimCols) - basePixmap.AnimFrameBorder * 2,
                        (mainTex.PixelHeight / basePixmap.AnimRows) - basePixmap.AnimFrameBorder * 2);
                    sprite.AnimDuration = 5.0f;
                    sprite.AnimFrameCount = basePixmap.AnimFrames;
                    convert.SuggestResultName(sprite, mat.Name);
                    results.Add(sprite);
                }

                convert.MarkObjectHandled(mat);
            }

            convert.AddResult(results);
            return false;
        }
开发者ID:SirePi,项目名称:duality,代码行数:51,代码来源:ComponentFromMaterial.cs

示例9: Convert

        public override bool Convert(ConvertOperation convert)
        {
            // If we already have a renderer in the result set, consider generating
            // a tilemap to be not the right course of action.
            if (convert.Result.OfType<ICmpRenderer>().Any())
                return false;

            List<object> results = new List<object>();
            List<Tileset> availData = convert.Perform<Tileset>().ToList();

            // Generate objects
            foreach (Tileset tileset in availData)
            {
                if (convert.IsObjectHandled(tileset)) continue;

                // Retrieve previously generated GameObjects and Tilemaps for re-use
                GameObject gameobj = convert.Result.OfType<GameObject>().FirstOrDefault();
                Tilemap tilemap = convert.Result.OfType<Tilemap>().FirstOrDefault();
                TilemapRenderer tilemapRenderer = convert.Result.OfType<TilemapRenderer>().FirstOrDefault();
                if (tilemap == null && gameobj != null) tilemap = gameobj.GetComponent<Tilemap>();

                // Create a new Tilemap (and TilemapRenderer) if none did exist before
                if (tilemap == null)
                {
                    tilemap = new Tilemap();
                    TilemapsSetupUtility.SetupTilemap(tilemap, tileset);

                    // Add a renderer for this Tilemap to the result list, if there was none before
                    if (tilemapRenderer == null)
                    {
                        results.Add(new TilemapRenderer());
                    }
                }

                // Configure the Tilemap according to the Tileset we're converting
                tilemap.Tileset = tileset;

                // Add the Tilemap to our result set
                results.Add(tilemap);
                convert.SuggestResultName(tilemap, tileset.Name);
                convert.MarkObjectHandled(tileset);
            }

            convert.AddResult(results);
            return false;
        }
开发者ID:SirePi,项目名称:duality,代码行数:46,代码来源:ComponentFromTileset.cs

示例10: Convert

        public override bool Convert(ConvertOperation convert)
        {
            bool finishConvertOp = false;
            List<AudioData> availData = convert.Perform<AudioData>().ToList();
            List<AudioData> createDataSource = null;

            // Match objects
            foreach (AudioData baseRes in availData)
            {
                if (convert.IsObjectHandled(baseRes)) continue;

                // Find target Resource matching the source
                Sound targetRes =
                    this.FindMatchingResources<AudioData,Sound>(baseRes, IsMatch)
                    .OrderBy(sound => sound.Data.Count)
                    .FirstOrDefault();
                if (targetRes != null)
                {
                    convert.AddResult(targetRes);
                }
                else if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
                {
                    if (createDataSource == null) createDataSource = new List<AudioData>();
                    createDataSource.Add(baseRes);
                }
                else
                {
                    // Can't handle this AudioData
                    continue;
                }

                finishConvertOp = true;
                convert.MarkObjectHandled(baseRes);
            }

            // Create objects
            if (createDataSource != null)
            {
                List<ContentRef<Sound>> createdSounds = EditorActions.AudioDataToSound.CreateMultipleFromAudioData(createDataSource.Ref());
                foreach (ContentRef<Sound> sound in createdSounds)
                    convert.AddResult(sound.Res);
            }

            return finishConvertOp;
        }
开发者ID:SirePi,项目名称:duality,代码行数:45,代码来源:SoundFromAudioData.cs

示例11: Convert

		public override bool Convert(ConvertOperation convert)
		{
			bool finishConvertOp = false;

			List<Material> availData = convert.Perform<Material>().ToList();

			// Append objects
			foreach (Material mat in availData)
			{
				if (convert.IsObjectHandled(mat)) continue;

				convert.AddResult(new BatchInfo(mat));
				finishConvertOp = true;
				convert.MarkObjectHandled(mat);
			}

			return finishConvertOp;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:18,代码来源:BatchInfoFromMaterial.cs

示例12: Convert

		public override bool Convert(ConvertOperation convert)
		{
			bool finishConvertOp = false;

			List<Texture> availData = convert.Perform<Texture>().ToList();

			// Append objects
			foreach (Texture baseRes in availData)
			{
				if (convert.IsObjectHandled(baseRes)) continue;
				if (!baseRes.BasePixmap.IsAvailable) continue;

				convert.AddResult(baseRes.BasePixmap.Res);
				finishConvertOp = true;
				convert.MarkObjectHandled(baseRes);
			}

			return finishConvertOp;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:19,代码来源:PixmapFromTexture.cs

示例13: Convert

		public override bool Convert(ConvertOperation convert)
		{
			if (convert.Data.ContainsContentRefs<Prefab>())
			{
				ContentRef<Prefab>[] dropdata = convert.Data.GetContentRefs<Prefab>();

				// Instantiate Prefabs
				foreach (ContentRef<Prefab> pRef in dropdata)
				{
					if (convert.IsObjectHandled(pRef.Res)) continue;
					if (!pRef.IsAvailable) continue;
					GameObject newObj = pRef.Res.Instantiate();
					if (newObj != null)
					{
						convert.AddResult(newObj);
						convert.MarkObjectHandled(pRef.Res);
					}
				}
			}
			// Don't finish convert operation - other converters miht contribute to the new GameObjects!
			return false; 
		}
开发者ID:Banbury,项目名称:duality,代码行数:22,代码来源:DataConverters.cs

示例14: Convert

		public override bool Convert(ConvertOperation convert)
		{
			List<Sound> availData = convert.Perform<Sound>().ToList();

			// Generate objects
			foreach (Sound snd in availData)
			{
				if (convert.IsObjectHandled(snd)) continue;

				GameObject gameobj = convert.Result.OfType<GameObject>().FirstOrDefault();
				SoundEmitter emitter = convert.Result.OfType<SoundEmitter>().FirstOrDefault();
				if (emitter == null && gameobj != null) emitter = gameobj.GetComponent<SoundEmitter>();
				if (emitter == null) emitter = new SoundEmitter();
				convert.SuggestResultName(emitter, snd.Name);
					
				SoundEmitter.Source source = new SoundEmitter.Source(snd);
				emitter.Sources.Add(source);

				convert.AddResult(emitter);
				convert.MarkObjectHandled(snd);
			}
			return false;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:23,代码来源:ComponentFromSound.cs

示例15: Convert

        public override bool Convert(ConvertOperation convert)
        {
            bool finishConvertOp = false;
            List<BatchInfo> availData = convert.Perform<BatchInfo>().ToList();

            // Generate objects
            foreach (BatchInfo info in availData)
            {
                if (convert.IsObjectHandled(info)) continue;

                // Auto-Generate Material
                string matName = "Material";
                if (!info.MainTexture.IsExplicitNull) matName = info.MainTexture.FullName;
                string matPath = PathHelper.GetFreePath(matName, Resource.GetFileExtByType<Material>());
                Material mat = new Material(info);
                mat.Save(matPath);

                convert.AddResult(mat);
                finishConvertOp = true;
                convert.MarkObjectHandled(info);
            }

            return finishConvertOp;
        }
开发者ID:sinithwar,项目名称:duality,代码行数:24,代码来源:MaterialFromBatchInfo.cs


注:本文中的ConvertOperation.MarkObjectHandled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。