Ejemplo n.º 1
0
    public static void Import(string assetPath)
    {
        GameObject gameObject     = EditorUtility.CreateGameObjectWithHideFlags("", HideFlags.HideInHierarchy);
        string     prefabFilePath = GetPrefabPath(assetPath);
        GameObject prefab         = PrefabUtility.CreatePrefab(prefabFilePath, gameObject, ReplacePrefabOptions.ReplaceNameBased);

        PSBAsset asset = ScriptableObject.CreateInstance <PSBAsset>();

        asset.name = Path.GetFileNameWithoutExtension(assetPath);
        asset.Load(assetPath);
        AssetDatabase.AddObjectToAsset(asset, prefabFilePath);

        ForkParticleEffect particleSystem = prefab.AddComponent <ForkParticleEffect>();

        particleSystem.PSBFile = asset;

        MeshRenderer mesh = prefab.AddComponent <MeshRenderer>();

        mesh.receiveShadows       = false;
        mesh.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
        mesh.lightProbeUsage      = UnityEngine.Rendering.LightProbeUsage.Off;
        mesh.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;

        prefab.AddComponent <MeshFilter>();

        GameObject.DestroyImmediate(gameObject);
    }