protected override void DeserializeFromData(DataObject data)
 {
     ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
     if (convert.CanPerform(this.editedCmpType))
     {
         var refQuery = convert.Perform(this.editedCmpType);
         if (refQuery != null)
         {
             Component[] refArray = refQuery.Cast<Component>().ToArray();
             this.component = (refArray != null && refArray.Length > 0) ? refArray[0] : null;
             this.PerformSetValue();
             this.PerformGetValue();
             this.OnEditingFinished(FinishReason.LeapValue);
         }
     }
     else if (convert.CanPerform(typeof(GameObject)))
     {
         GameObject obj = convert.Perform<GameObject>().FirstOrDefault();
         Component cmp = obj != null ? obj.GetComponent(this.editedCmpType) : null;
         if (cmp != null)
         {
             this.component = cmp;
             this.PerformSetValue();
             this.PerformGetValue();
             this.OnEditingFinished(FinishReason.LeapValue);
         }
     }
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
		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;
		}
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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.VertexTypeIndex ||
                    tech.PreferredVertexFormat == VertexC1P3T4A4A1.VertexTypeIndex;
                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.AlignCenter(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.AlignCenter(
                        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;
        }
Exemplo n.º 7
0
		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;
		}
        protected override bool CanDeserializeFromData(DataObject data)
        {
            ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
            if (convert.CanPerform(this.editedCmpType)) return true;

            if (convert.CanPerform(typeof(GameObject)))
            {
                GameObject obj = convert.Perform<GameObject>().FirstOrDefault();
                return obj != null && obj.GetComponent(this.editedCmpType) != null;
            }

            return false;
        }
Exemplo n.º 9
0
        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;
        }
        protected override void DeserializeFromData(DataObject data)
        {
            ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);

            if (convert.CanPerform(this.editedResType))
            {
                var refQuery = convert.Perform(this.editedResType);
                if (refQuery != null)
                {
                    Resource[] refArray = refQuery.Cast <Resource>().ToArray();
                    UpdateContentPath((refArray != null && refArray.Length > 0) ? refArray[0].Path : null);
                }
            }
        }
Exemplo n.º 11
0
        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.FindMatch(baseRes);
                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 = Sound.CreateMultipleFromAudioData(createDataSource.Ref());
                foreach (ContentRef <Sound> sound in createdSounds)
                {
                    convert.AddResult(sound.Res);
                }
            }

            return(finishConvertOp);
        }
Exemplo n.º 12
0
        public override bool CanConvertFrom(ConvertOperation convert)
        {
            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
            {
                return(convert.CanPerform <Pixmap>());
            }

            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert))
            {
                List <Pixmap> availData = convert.Perform <Pixmap>(ConvertOperation.Operation.Convert).ToList();
                return(availData.Any(t => this.FindMatch(t) != null));
            }

            return(false);
        }
Exemplo n.º 13
0
        public override bool CanConvertFrom(ConvertOperation convert)
        {
            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
            {
                return convert.CanPerform<Pixmap>();
            }

            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert))
            {
                List<Pixmap> availData = convert.Perform<Pixmap>(ConvertOperation.Operation.Convert).ToList();
                return availData.Any(t => this.FindMatch(t) != null);
            }

            return false;
        }
 protected override void DeserializeFromData(DataObject data)
 {
     ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
     if (convert.CanPerform(typeof(GameObject)))
     {
         var refQuery = convert.Perform(typeof(GameObject));
         if (refQuery != null)
         {
             GameObject[] refArray = refQuery.Cast<GameObject>().ToArray();
             this.gameObj = (refArray != null && refArray.Length > 0) ? refArray[0] : null;
             this.PerformSetValue();
             this.PerformGetValue();
             this.OnEditingFinished(FinishReason.LeapValue);
         }
     }
 }
Exemplo n.º 15
0
        protected override void DeserializeFromData(DataObject data)
        {
            ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);

            if (convert.CanPerform(typeof(GameObject)))
            {
                var refQuery = convert.Perform(typeof(GameObject));
                if (refQuery != null)
                {
                    GameObject[] refArray = refQuery.Cast <GameObject>().ToArray();
                    this.gameObj = (refArray != null && refArray.Length > 0) ? refArray[0] : null;
                    this.PerformSetValue();
                    this.PerformGetValue();
                    this.OnEditingFinished(FinishReason.LeapValue);
                }
            }
        }
Exemplo n.º 16
0
        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;
        }
Exemplo n.º 17
0
        public override bool CanConvertFrom(ConvertOperation convert)
        {
            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
            {
                return(convert.CanPerform <AudioData>());
            }

            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert))
            {
                List <AudioData> availData = convert.Perform <AudioData>(ConvertOperation.Operation.Convert).ToList();
                return(availData.Any(t =>
                                     this.FindMatchingResources <AudioData, Sound>(t, IsMatch)
                                     .Any()));
            }

            return(false);
        }
Exemplo n.º 18
0
        public override bool CanConvertFrom(ConvertOperation convert)
        {
            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
            {
                return convert.CanPerform<Texture>();
            }

            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert))
            {
                List<Texture> availData = convert.Perform<Texture>(ConvertOperation.Operation.Convert).ToList();
                return availData.Any(t =>
                    this.FindMatchingResources<Texture,Material>(t, IsMatch)
                    .Any());
            }

            return false;
        }
Exemplo n.º 19
0
        protected override bool CanDeserializeFromData(DataObject data)
        {
            ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);

            if (convert.CanPerform(this.editedCmpType))
            {
                return(true);
            }

            if (convert.CanPerform(typeof(GameObject)))
            {
                GameObject obj = convert.Perform <GameObject>().FirstOrDefault();
                return(obj != null && obj.GetComponent(this.editedCmpType) != null);
            }

            return(false);
        }
Exemplo n.º 20
0
        protected override void DeserializeFromData(DataObject data)
        {
            ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);

            if (convert.CanPerform(this.editedResType))
            {
                var refQuery = convert.Perform(this.editedResType);
                if (refQuery != null)
                {
                    Resource[] refArray = refQuery.Cast <Resource>().ToArray();
                    this.contentPath = (refArray != null && refArray.Length > 0) ? refArray[0].Path : null;
                    this.PerformSetValue();
                    this.PerformGetValue();
                    this.OnEditingFinished(FinishReason.LeapValue);
                }
            }
        }
Exemplo n.º 21
0
        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;
        }
Exemplo n.º 22
0
		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;
		}
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
		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;
		}
Exemplo n.º 25
0
        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(mat.Info);
                finishConvertOp = true;
                convert.MarkObjectHandled(mat);
            }

            return(finishConvertOp);
        }
Exemplo n.º 26
0
        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.
                Tileset targetRes =
                    this.FindMatchingResources <Pixmap, Tileset>(baseRes, IsMatch)
                    .FirstOrDefault();
                if (targetRes == null && convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
                {
                    string texPath = PathHelper.GetFreePath(baseRes.FullName, Resource.GetFileExtByType <Tileset>());
                    targetRes = new Tileset();
                    targetRes.RenderConfig.Add(new TilesetRenderInput
                    {
                        SourceData = baseRes
                    });
                    targetRes.Compile();
                    targetRes.Save(texPath);
                }

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

            return(finishConvertOp);
        }
Exemplo n.º 27
0
		protected override void OnDragDrop(DragEventArgs e)
		{
			// Check children first. Only accept the drop if they don't
			e.Effect = DragDropEffects.None;
			base.OnDragDrop(e);
			if (e.Effect != DragDropEffects.None) return;

			DataObject dragDropData = e.Data as DataObject;
			if (!this.ReadOnly && dragDropData != null)
			{
				ConvertOperation convert = new ConvertOperation(dragDropData, ConvertOperation.Operation.All);
				if (convert.CanPerform<Sound>())
				{
					// Accept drop
					e.Effect = e.AllowedEffect;

					UndoRedoManager.Do(new CreateSoundEmitterSourceAction(
						this.GetValue().Cast<SoundEmitter>(), 
						convert.Perform<Sound>().Select(s => new SoundEmitter.Source(s))));
				}
			}
		}
Exemplo n.º 28
0
		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;
		}
Exemplo n.º 29
0
        public override bool Convert(ConvertOperation convert)
        {
            bool finishConvertOp = false;

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

            // Append objects
            foreach (Sound baseRes in availData)
            {
                if (convert.IsObjectHandled(baseRes)) continue;
                if (baseRes.Data != null)
                {
                    for (int i = 0; i < baseRes.Data.Count; i++)
                    {
                        if (!baseRes.Data[i].IsAvailable) continue;
                        convert.AddResult(baseRes.Data[i].Res);
                        finishConvertOp = true;
                    }
                }
                convert.MarkObjectHandled(baseRes);
            }

            return finishConvertOp;
        }
Exemplo n.º 30
0
        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;
        }
Exemplo n.º 31
0
        protected override int GetPreviewHash()
        {
            if (this.contentPath == null) return 0;

            IContentRef contentRef = new ContentRef<Resource>(null, this.contentPath);
            if (!contentRef.IsAvailable) return 0;

            ConvertOperation convOp = new ConvertOperation(new[] { contentRef.Res }, ConvertOperation.Operation.Convert);
            if (convOp.CanPerform<Pixmap>())
            {
                Pixmap basePx = convOp.Perform<Pixmap>().FirstOrDefault();
                PixelData basePxLayer = basePx != null ? basePx.MainLayer : null;
                return basePxLayer != null ? basePxLayer.GetHashCode() : 0;
            }
            else if (convOp.CanPerform<AudioData>())
            {
                AudioData audioData = convOp.Perform<AudioData>().FirstOrDefault();
                return (audioData != null && audioData.OggVorbisData != null) ? audioData.OggVorbisData.GetHashCode() : 0;
            }

            return this.contentPath.GetHashCode();
        }
Exemplo n.º 32
0
        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);
        }
Exemplo n.º 33
0
 protected override void DeserializeFromData(DataObject data)
 {
     ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
     if (convert.CanPerform(this.editedResType))
     {
         var refQuery = convert.Perform(this.editedResType);
         if (refQuery != null)
         {
             Resource[] refArray = refQuery.Cast<Resource>().ToArray();
             this.contentPath = (refArray != null && refArray.Length > 0) ? refArray[0].Path : null;
             this.PerformSetValue();
             this.PerformGetValue();
             this.OnEditingFinished(FinishReason.LeapValue);
         }
     }
 }
Exemplo n.º 34
0
        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.VertexTypeIndex ||
                                         tech.PreferredVertexFormat == VertexC1P3T4A4A1.VertexTypeIndex;
                if (!isDynamicLighting)
                {
                    continue;
                }

                Texture    mainTex = mat.MainTexture.Res;
                GameObject gameobj = convert.Result.OfType <GameObject>().FirstOrDefault();

                if (mainTex == null || mainTex.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.AlignCenter(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.AlignCenter(0.0f, 0.0f, mainTex.PixelWidth / mainTex.AnimCols, mainTex.PixelHeight / mainTex.AnimRows);
                    sprite.AnimDuration   = 5.0f;
                    sprite.AnimFrameCount = mainTex.AnimFrames;
                    convert.SuggestResultName(sprite, mat.Name);
                    results.Add(sprite);
                }

                convert.MarkObjectHandled(mat);
            }

            convert.AddResult(results);
            return(false);
        }
Exemplo n.º 35
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.C && e.Control)
            {
                DataObject data = new DataObject();
                data.SetBatchInfos(new[] { this.DisplayedValue as BatchInfo });
                Clipboard.SetDataObject(data);
                e.Handled = true;
            }
            else if (e.KeyCode == Keys.V && e.Control)
            {
                DataObject data = Clipboard.GetDataObject() as DataObject;
                ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
                IEnumerable<BatchInfo> refQuery = null;
                if (convert.CanPerform<BatchInfo>() && (refQuery = convert.Perform<BatchInfo>()) != null)
                {
                    this.SetValue(refQuery.FirstOrDefault());
                    this.PerformGetValue();
                    this.OnEditingFinished(FinishReason.LeapValue);
                }
                else
                    System.Media.SystemSounds.Beep.Play();

                e.Handled = true;
            }
            base.OnKeyDown(e);
        }
 protected override void DeserializeFromData(DataObject data)
 {
     ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
     if (convert.CanPerform(this.editedResType))
     {
         var refQuery = convert.Perform(this.editedResType);
         if (refQuery != null)
         {
             Resource[] refArray = refQuery.Cast<Resource>().ToArray();
             UpdateContentPath((refArray != null && refArray.Length > 0) ? refArray[0].Path : null);
         }
     }
 }
Exemplo n.º 37
0
        private void objectView_DragDrop(object sender, DragEventArgs e)
        {
            this.objectView.BeginUpdate();

            bool effectMove = (e.Effect & DragDropEffects.Move) != DragDropEffects.None;
            bool effectCopy = (e.Effect & DragDropEffects.Copy) != DragDropEffects.None;
            DataObject data = e.Data as DataObject;
            if (data != null)
            {
                ConvertOperation convertOp = new ConvertOperation(data, ConvertOperation.Operation.All);
                this.tempDropTarget = this.DragDropGetTargetNode();
                if (data.ContainsGameObjectRefs())
                {
                    this.tempDropData = data.GetGameObjectRefs();

                    // Display context menu if both moving and copying are availabled
                    if (effectMove && effectCopy)
                        this.contextMenuDragMoveCopy.Show(this, this.PointToClient(new Point(e.X, e.Y)));
                    else if (effectCopy)
                        this.copyHereToolStripMenuItem_Click(this, null);
                    else if (effectMove)
                        this.moveHereToolStripMenuItem_Click(this, null);
                }
                else if (data.ContainsComponentRefs())
                {
                    this.tempDropData = data.GetComponentRefs();

                    // Display context menu if both moving and copying are availabled
                    if (effectMove && effectCopy)
                        this.contextMenuDragMoveCopy.Show(this, this.PointToClient(new Point(e.X, e.Y)));
                    else if (effectCopy)
                        this.copyHereToolStripMenuItem_Click(this, null);
                    else if (effectMove)
                        this.moveHereToolStripMenuItem_Click(this, null);
                }
                else if (this.tempDropTarget != null && convertOp.CanPerform<Component>())
                {
                    GameObject dropObj = null;
                    if (this.tempDropTarget is GameObjectNode)
                        dropObj = (this.tempDropTarget as GameObjectNode).Obj;
                    else
                        dropObj = (this.tempDropTarget as ComponentNode).Component.GameObj;

                    var componentQuery = convertOp.Perform<Component>();
                    if (componentQuery != null)
                    {
                        // Create Components
                        CreateComponentAction createAction = new CreateComponentAction(dropObj, componentQuery.Where(c => c.GameObj == null));
                        UndoRedoManager.BeginMacro();
                        UndoRedoManager.Do(new DeleteComponentAction(componentQuery.Select(c => dropObj.GetComponent(c.GetType())).NotNull()));
                        UndoRedoManager.Do(createAction);
                        UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromLast);

                        bool selCleared = false;
                        foreach (Component newComponent in createAction.Result)
                        {
                            NodeBase dataNode = this.FindNode(newComponent);
                            if (dataNode == null) continue;
                            TreeNodeAdv viewNode = this.objectView.FindNode(this.objectModel.GetPath(dataNode));
                            if (viewNode == null) continue;
                            if (!selCleared)
                            {
                                this.objectView.ClearSelection();
                                selCleared = true;
                            }
                            viewNode.IsSelected = true;
                            this.objectView.EnsureVisible(viewNode);
                        }
                    }
                }
                else if (convertOp.CanPerform<GameObject>())
                {
                    GameObject dropObj = (this.tempDropTarget is GameObjectNode) ? (this.tempDropTarget as GameObjectNode).Obj : null;
                    var gameObjQuery = convertOp.Perform<GameObject>();
                    if (gameObjQuery != null)
                    {
                        CreateGameObjectAction action = new CreateGameObjectAction(dropObj, gameObjQuery);
                        UndoRedoManager.Do(action);

                        bool selCleared = false;
                        foreach (GameObject newObj in action.Result)
                        {
                            NodeBase dataNode = this.FindNode(newObj);
                            if (dataNode == null) continue;
                            TreeNodeAdv viewNode = this.objectView.FindNode(this.objectModel.GetPath(dataNode));
                            if (viewNode == null) continue;
                            if (!selCleared)
                            {
                                this.objectView.ClearSelection();
                                selCleared = true;
                            }
                            viewNode.IsSelected = true;
                            this.objectView.EnsureVisible(viewNode);
                        }
                    }
                }
            }

            this.objectView.EndUpdate();
        }
Exemplo n.º 38
0
		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;
				Texture mainTex = mat.MainTexture.Res;
				GameObject gameobj = convert.Result.OfType<GameObject>().FirstOrDefault();

				if (mainTex == null || mainTex.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.AlignCenter(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.AlignCenter(0.0f, 0.0f, mainTex.PixelWidth / mainTex.AnimCols, mainTex.PixelHeight / mainTex.AnimRows);
					sprite.AnimDuration = 5.0f;
					sprite.AnimFrameCount = mainTex.AnimFrames;
					convert.SuggestResultName(sprite, mat.Name);
					results.Add(sprite);
				}

				convert.MarkObjectHandled(mat);
			}

			convert.AddResult(results);
			return false;
		}
Exemplo n.º 39
0
        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();
                bool       hasAnimation = (mainTex != null && basePixmap != null && basePixmap.Atlas != null && basePixmap.Atlas.Count > 0);

                // Determine the size of the displayed sprite
                Vector2 spriteSize;
                if (hasAnimation)
                {
                    Rect atlasRect = basePixmap.LookupAtlas(0);
                    spriteSize = atlasRect.Size;
                }
                else if (mainTex != null)
                {
                    spriteSize = mainTex.ContentSize;

                    // If we're dealing with default content, clamp sprite size to
                    // something easily visible in order to avoid 1x1 sprites for
                    // default White / Black or similar fallback textures.
                    if (mainTex.IsDefaultContent)
                    {
                        spriteSize = Vector2.Max(spriteSize, new Vector2(32.0f, 32.0f));
                    }
                }
                else
                {
                    spriteSize = Pixmap.Checkerboard.Res.Size;
                }

                // Create a sprite Component in any case
                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;
                sprite.Rect           = Rect.Align(Alignment.Center, 0.0f, 0.0f, spriteSize.X, spriteSize.Y);
                results.Add(sprite);

                // If we have animation data, create an animator component as well
                if (hasAnimation)
                {
                    SpriteAnimator animator = convert.Result.OfType <SpriteAnimator>().FirstOrDefault();
                    if (animator == null && gameobj != null)
                    {
                        animator = gameobj.GetComponent <SpriteAnimator>();
                    }
                    if (animator == null)
                    {
                        animator = new SpriteAnimator();
                    }
                    animator.AnimDuration = 5.0f;
                    animator.FrameCount   = basePixmap.Atlas.Count;
                    results.Add(animator);
                }

                convert.SuggestResultName(sprite, mat.Name);
                convert.MarkObjectHandled(mat);
            }

            convert.AddResult(results);
            return(false);
        }
Exemplo n.º 40
0
        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);
        }
Exemplo n.º 41
0
        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;
                }

                DrawTechnique tech = mat.Technique.Res;
                if (tech == null)
                {
                    continue;
                }

                bool isDynamicLighting =
                    tech is LightingTechnique ||
                    tech.PreferredVertexFormat == VertexDynamicLighting.Declaration;
                if (!isDynamicLighting)
                {
                    continue;
                }

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

                // Determine the size of the displayed sprite
                Vector2 spriteSize;
                if (hasAnimation)
                {
                    Rect atlasRect = basePixmap.LookupAtlas(0);
                    spriteSize = atlasRect.Size;
                }
                else if (mainTex != null)
                {
                    spriteSize = mainTex.ContentSize;
                }
                else
                {
                    spriteSize = Pixmap.Checkerboard.Res.Size;
                }

                // Create a sprite Component in any case
                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;
                sprite.Rect           = Rect.Align(Alignment.Center, 0.0f, 0.0f, spriteSize.X, spriteSize.Y);
                results.Add(sprite);

                // If we have animation data, create an animator component as well
                if (hasAnimation)
                {
                    SpriteAnimator animator = convert.Result.OfType <SpriteAnimator>().FirstOrDefault();
                    if (animator == null && gameobj != null)
                    {
                        animator = gameobj.GetComponent <SpriteAnimator>();
                    }
                    if (animator == null)
                    {
                        animator = new SpriteAnimator();
                    }
                    animator.AnimDuration = 5.0f;
                    animator.FrameCount   = basePixmap.Atlas.Count;
                    results.Add(animator);
                }

                convert.SuggestResultName(sprite, mat.Name);
                convert.MarkObjectHandled(mat);
            }

            convert.AddResult(results);
            return(false);
        }