Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom properties lost #21

Open
Crikster opened this issue Jun 11, 2021 · 10 comments · May be fixed by #42
Open

Custom properties lost #21

Crikster opened this issue Jun 11, 2021 · 10 comments · May be fixed by #42
Assignees

Comments

@Crikster
Copy link

Hi, i think it wold be amazing if theres an option to export custom properties, they are getting lost in the way.

thanks!!
Cris

@EdyJ
Copy link
Owner

EdyJ commented Jun 11, 2021

I'm definitely interested in this. Could you provide an example file with those custom properties? Also, please describe how to read them in Unity.

@Crikster
Copy link
Author

Sure no problem, here a link with a blender file, and some screenshots.
https://www.dropbox.com/sh/l3sm891mncvzxaj/AADCgZ6MFXqgTavGCQl7lXMla?dl=0
So basically the custom properties are just Generic properties the user can define, in my case i am using it for filtering of objects. to create different variations.
in the screenshots:

Blender:
-object custom properties ubication.
-blender default fbx export location of custom properties.

Unity:
-Unity screenshot of my custom script to load this custom properties and filter dynamically.

hope this helps! and thanks for the interest!

@EdyJ
Copy link
Owner

EdyJ commented Jun 11, 2021

Thank you for the file and the screenshots! In your custom script, which Unity API methods are you using to access the custom properties? I'll write a simple script to test they work.

@Crikster
Copy link
Author

Crikster commented Jul 2, 2021

HI sorry for my delayed answer, is a custom script done by another company :(

@EdyJ
Copy link
Owner

EdyJ commented Jul 2, 2021

I shouldn't need the entire script, only the Unity API methods and properties being used. Please understand that I need to be able to reproduce the case in Unity in order to fix it.

@EdyJ
Copy link
Owner

EdyJ commented Jul 13, 2021

Closing this issue, as I have no way to reproduce it in Unity.

@EdyJ EdyJ closed this as completed Jul 13, 2021
@EdyJ EdyJ added the can't reproduce The issue cannot be reproduced label Jul 13, 2021
@swingingtom
Copy link

@EdyJ thanks for the plugin 👍. I was struggling with nested empties

I can confirm that custom properties are lost during export.
The way to check it in unity is to make a AssetPostProcessor script that post process models, similar to what is there https://docs.unity3d.com/ScriptReference/AssetPostprocessor.OnPostprocessGameObjectWithUserProperties.html

Here is one, paste it in a unity asset folder. It simply lists all custom properties found in FBX.
FBXCustomPropertiesListing

using System;
using UnityEditor;
using UnityEngine;

    public class FBXCustomPropertiesListing: AssetPostprocessor
    {
        void OnPostprocessGameObjectWithUserProperties(GameObject go, string[] propNames, System.Object[] values)
        {
            for (int i = 0; i < propNames.Length; i++)
            {
                string propName = propNames[i];
                System.Object value = (System.Object)values[i];
                Debug.Log("Propname: " + propName + " value: " + values[i]);
            }
        }
    }

If you need a complete unity project with files and scripts, I can provide it too.

@swingingtom
Copy link

From the blender fbx exporter, this is use_custom_props parameter
https://docs.blender.org/api/current/bpy.ops.export_scene.html

@swingingtom swingingtom linked a pull request Oct 1, 2023 that will close this issue
@EdyJ
Copy link
Owner

EdyJ commented Dec 11, 2023

Thank you so much for the AssetPostProcessor example! Also, thank you for the pull request. I'll check it out, but most likely I'll just enable use_custom_props parameter internally. I can't see any reason for disabling it.

@EdyJ EdyJ reopened this Dec 11, 2023
@EdyJ EdyJ self-assigned this Dec 11, 2023
@EdyJ EdyJ removed the can't reproduce The issue cannot be reproduced label Dec 11, 2023
@swingingtom
Copy link

After asking the request, I felt guilty for not even trying to dive into the source, and I had many excuses, you know, never write python before, that's not my library, not aware of blender plugins, whatever...

But at the end, I manage to, and that was pretty satisfying :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants