Ejemplo n.º 1
0
 private static void OnFbxUpdate(FbxPrefab updatedInstance, IEnumerable <GameObject> updatedObjects)
 {
     // System.Text.StringBuilder sb = new System.Text.StringBuilder();
     // sb.AppendLine("OnFbxUpdate:");
     // sb.AppendLine("instance: " + updatedInstance.name + " is asset: " + !string.IsNullOrEmpty(AssetDatabase.GetAssetPath(updatedInstance)));
     // sb.AppendLine("objects:");
     // foreach(GameObject go in updatedObjects)
     //  sb.AppendLine("\t" + go.name);
     // pb_Log.Debug(sb.ToString());
 }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            SerializedProperty m_GameObjectProp = serializedObject.FindProperty("m_nameMapping");

            FbxPrefab fbxPrefab = (FbxPrefab)target;

            // We can only change these settings when applied to a prefab.
            bool isDisabled = string.IsNullOrEmpty(AssetDatabase.GetAssetPath(fbxPrefab));

            if (isDisabled)
            {
                EditorGUILayout.HelpBox("Please select a prefab. You can't edit an instance in the scene.",
                                        MessageType.Info);
            }

            EditorGUI.BeginDisabledGroup(isDisabled);
            FbxPrefabUtility fbxPrefabUtility = new FbxPrefabUtility(fbxPrefab);
            var oldFbxAsset = fbxPrefabUtility.FbxAsset;
            var newFbxAsset = EditorGUILayout.ObjectField(new GUIContent("Source FBX Asset", "The FBX file that is linked to this Prefab"), oldFbxAsset,
                                                          typeof(GameObject), allowSceneObjects: false) as GameObject;

            if (newFbxAsset && !FbxPrefabAutoUpdater.IsFbxAsset(UnityEditor.AssetDatabase.GetAssetPath(newFbxAsset)))
            {
                Debug.LogError("FbxPrefab must point to an FBX asset (or none).");
            }
            else if (newFbxAsset != oldFbxAsset)
            {
                fbxPrefabUtility.SetSourceModel(newFbxAsset);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.PropertyField(m_GameObjectProp, true);

#if FBXEXPORTER_DEBUG
            if (GUILayout.Button("Update prefab manually..."))
            {
                // Get existing open window or if none, make a new one:
                ManualUpdateEditorWindow window = (ManualUpdateEditorWindow)EditorWindow.GetWindow(typeof(ManualUpdateEditorWindow));
                window.Init(fbxPrefabUtility, fbxPrefab);
                window.Show();
            }

            EditorGUILayout.LabelField("Debug info:");
            try {
                fbxPrefabUtility.GetFbxHistory().ToJson();
            } catch (System.Exception xcp) {
                Debug.LogException(xcp);
            }
            EditorGUILayout.SelectableLabel(fbxPrefabUtility.GetFbxHistoryString());
#endif
            serializedObject.ApplyModifiedProperties();
        }
        public void Init(FbxPrefabUtility fbxPrefabUtility, FbxPrefab fbxPrefab)
        {
            if (fbxPrefab == null)
            {
                return;
            }

            FbxPrefabUtility.UpdateList updates = new FbxPrefabUtility.UpdateList(new FbxRepresentation(fbxPrefab.FbxHistory), fbxPrefab.FbxModel.transform, fbxPrefab);

            m_fbxPrefabUtility = fbxPrefabUtility;
            m_fbxPrefab        = fbxPrefab;
            // Convert Hashset into List
            m_nodesToCreate  = updates.NodesToCreate.ToList();
            m_nodesToDestroy = updates.NodesToDestroy.ToList();
            m_nodesToRename  = updates.NodesToRename.ToList();
            // Create the dropdown list
            m_nodeNameToSuggest = new List <string>();
            m_nodeNameToSuggest.AddRange(m_nodesToCreate);
            m_nodeNameToSuggest.AddRange(m_nodesToRename);

            // Keep track of the selected combo option in each type
            selectedNodesToDestroy = new int[m_nodesToDestroy.Count];
            selectedNodesToRename  = new int[m_nodesToRename.Count];

            // Default option for nodes to rename. Shows the current name mapping
            for (int i = 0; i < m_nodesToRename.Count; i++)
            {
                for (int j = 0; j < m_nodeNameToSuggest.Count; j++)
                {
                    if (m_nodeNameToSuggest[j] == m_nodesToRename[i])
                    {
                        // Add extra 1 for the [Delete] option
                        selectedNodesToRename[i] = j + 1;
                    }
                }
            }
        }
 public bool CallbackForFbxPrefab(ModelExporter exporter, FbxPrefab component, FbxNode fbxNode)
 {
     componentCalls++;
     return(true);
 }