Beispiel #1
0
 static public BurstAudioClip CreateBurstAudioClip(this AudioClip audio_clip)
 {
     return(CustomAssets.CreateExternalCustomAsset <BurstAudioClip>(
                Filename.SetExtension(audio_clip.GetAssetPath(), "asset"),
                s => s.Initialize(audio_clip)
                ));
 }
Beispiel #2
0
 static public OctoTile CreateSimpleTerrainTile(this Texture2D item)
 {
     return(CustomAssets.CreateExternalCustomAsset <OctoTile>(
                Filename.SetExtension(item.GetAssetPath(), "asset"),
                s => s.Initialize(item.GetSprites())
                ));
 }
Beispiel #3
0
 static public SequencedSprite CreateSimpleSequencedSprite(this Texture2D texture)
 {
     return(CustomAssets.CreateExternalCustomAsset <SequencedSprite>(
                Filename.SetExtension(texture.GetAssetPath(), "asset"),
                s => s.Initialize(new SpriteSequence(texture.GetSprites()))
                ));
 }
Beispiel #4
0
 static public BurstSprite CreateBurstSprite(this Texture2D texture)
 {
     return(CustomAssets.CreateExternalCustomAsset <BurstSprite>(
                Filename.SetExtension(texture.GetAssetPath(), "asset"),
                s => s.Initialize(1.0f, texture.GetSprites())
                ));
 }
Beispiel #5
0
        static private void GenerateSequencedSpriteMenuItems()
        {
            CodeGenerator.GenerateStaticClass("SequencedSpriteMenuItems", delegate(CSTextDocumentBuilder builder) {
                foreach (SequencedSpriteFormat format in CustomAssets.GetExternalCustomAssetsOfType <SequencedSpriteFormat>())
                {
                    CSTextDocumentWriter writer = builder.CreateWriterWithVariablePairs(
                        "PATH", ("Assets/Sprite/Create/Sequenced/" + format.name).StyleAsDoubleQuoteLiteral(),
                        "FUNCTION_EXECUTE", ("Execute" + format.name).StyleAsFunctionName(),
                        "FUNCTION_VALIDATE", ("Validate" + format.name).StyleAsFunctionName(),
                        "FORMAT_PATH", format.GetAssetPath().StyleAsDoubleQuoteLiteral()
                        );

                    writer.Write("[MenuItem(?PATH)]");
                    writer.Write("static public void ?FUNCTION_EXECUTE()", delegate() {
                        writer.Write("AssetDatabase.LoadAssetAtPath<SequencedSpriteFormat>(?FORMAT_PATH).CreateSequencedSprite(Selection.activeObject as Texture2D);");
                    });

                    writer.Write("[MenuItem(?PATH, true)]");
                    writer.Write("static public bool ?FUNCTION_VALIDATE()", delegate() {
                        writer.Write("if(Selection.activeObject is Texture2D)", delegate() {
                            writer.Write("return true;");
                        });

                        writer.Write("return false;");
                    });
                }
            }, GeneratedCodeType.EditorOnlyLeaf);
        }
Beispiel #6
0
 public AnimatedSprite CreateAnimatedSprite(Texture2D texture)
 {
     return(CustomAssets.CreateExternalCustomAsset <AnimatedSprite>(
                Filename.SetExtension(texture.GetAssetPath(), "asset"),
                s => s.Initialize(
                    animation_formats.Convert(f => f.CreateSpriteAnimation(texture))
                    )
                ));
 }
Beispiel #7
0
        static private void GenerateSpriteVectorizerMenuItems()
        {
            CodeGenerator.GenerateStaticClass("SpriteVectorizerMenuItems", delegate(CSTextDocumentBuilder builder) {
                foreach (SpriteVectorizer vectorizer in CustomAssets.GetExternalCustomAssetsOfType <SpriteVectorizer>())
                {
                    CSTextDocumentWriter writer = builder.CreateWriterWithVariablePairs(
                        "SPRITE_PATH", ("Assets/Sprite/Generate/Collider/" + vectorizer.name).StyleAsDoubleQuoteLiteral(),
                        "TEXTURE_PATH", ("Assets/Sprite/Generate/Colliders/" + vectorizer.name).StyleAsDoubleQuoteLiteral(),
                        "FUNCTION_SPRITE_EXECUTE", ("ExecuteSprite" + vectorizer.name).StyleAsFunctionName(),
                        "FUNCTION_SPRITE_VALIDATE", ("ValidateSprite" + vectorizer.name).StyleAsFunctionName(),
                        "FUNCTION_TEXTURE_EXECUTE", ("ExecuteTexture" + vectorizer.name).StyleAsFunctionName(),
                        "FUNCTION_TEXTURE_VALIDATE", ("ValidateTexture" + vectorizer.name).StyleAsFunctionName(),
                        "VECTORIZER_PATH", vectorizer.GetAssetPath().StyleAsDoubleQuoteLiteral()
                        );

                    writer.Write("[MenuItem(?SPRITE_PATH)]");
                    writer.Write("static public void ?FUNCTION_SPRITE_EXECUTE()", delegate() {
                        writer.Write("(Selection.activeObject as Sprite).GenerateSpriteCollider(AssetDatabase.LoadAssetAtPath<SpriteVectorizer>(?VECTORIZER_PATH));");
                    });

                    writer.Write("[MenuItem(?SPRITE_PATH, true)]");
                    writer.Write("static public bool ?FUNCTION_SPRITE_VALIDATE()", delegate() {
                        writer.Write("if(Selection.activeObject is Sprite)", delegate() {
                            writer.Write("return true;");
                        });

                        writer.Write("return false;");
                    });

                    writer.Write("[MenuItem(?TEXTURE_PATH)]");
                    writer.Write("static public void ?FUNCTION_TEXTURE_EXECUTE()", delegate() {
                        writer.Write("(Selection.activeObject as Texture2D).GenerateSpriteColliders(AssetDatabase.LoadAssetAtPath<SpriteVectorizer>(?VECTORIZER_PATH));");
                    });

                    writer.Write("[MenuItem(?TEXTURE_PATH, true)]");
                    writer.Write("static public bool ?FUNCTION_TEXTURE_VALIDATE()", delegate() {
                        writer.Write("if(Selection.activeObject is Texture2D)", delegate() {
                            writer.Write("return true;");
                        });

                        writer.Write("return false;");
                    });
                }
            }, GeneratedCodeType.EditorOnlyLeaf);
        }
Beispiel #8
0
        protected override EditorGUIElement PushState()
        {
            CustomAsset asset;
            EditProperty_Single_Value property = GetProperty();

            Type field_type = property.GetPropertyType();

            EditorGUIElement_Container_Auto      container      = new EditorGUIElement_Container_Auto_Simple_VerticalStrip();
            EditorGUIElement_Container_Flow_Line type_container = container.AddChild(new EditorGUIElement_Container_Flow_Line());

            if (property.TryGetContentValues <CustomAsset>(out asset, true))
            {
                switch (asset.GetAssetType())
                {
                case AssetType.None:
                case AssetType.External:
                    type_container.AddWeightedChild(1.0f,
                                                    new EditorGUIElement_EditPropertySingleValue_Selector_Asset(property, false)
                                                    );
                    break;

                case AssetType.Internal:
                    type_container.AddWeightedChild(1.0f,
                                                    new EditorGUIElement_Popup_ProcessOperation <Type>(
                                                        GetInternalCustomAssetTypes(field_type),
                                                        t => property.SetContentValues(CustomAssets.CreateInternalCustomAsset(t)),
                                                        (out Type t) => property.TryGetContentsType(out t)
                                                        )
                                                    );
                    break;
                }

                type_container.AddFixedChild(64.0f, new EditorGUIElement_Process(delegate(Rect rect) {
                    AssetType new_type = EditorGUIExtensions.EnumPopup(rect, asset.GetAssetType());

                    if (asset.GetAssetType() != new_type)
                    {
                        switch (new_type)
                        {
                        case AssetType.None:
                            property.SetContentValues(null);
                            break;

                        case AssetType.External:
                            property.SetContentValues(
                                CustomAssets.GetExternalCustomAssetsOfType(field_type)
                                .GetFirst()
                                );
                            break;

                        case AssetType.Internal:
                            property.SetContentValues(
                                CustomAssets.CreateInternalCustomAsset(
                                    GetInternalCustomAssetTypes(field_type)
                                    .GetFirst()
                                    )
                                );
                            break;
                        }
                    }
                }));

                if (asset != null && asset.IsInternalAsset())
                {
                    container.AddChild(new EditorGUIElement_Complex_EditTarget(new EditTarget(asset)));
                }
            }

            return(container);
        }