@@ -44,11 +44,22 @@ public class FbxPrefab : MonoBehaviour
44
44
// component is really only about the editor.
45
45
#if UNITY_EDITOR
46
46
47
+ /// <summary>
48
+ /// Utility function: log a message, make clear it's the prefab update.
49
+ /// </summary>
50
+ [ System . Diagnostics . Conditional ( "FBXEXPORTER_DEBUG" ) ]
51
+ public static void Log ( string message ) {
52
+ Debug . Log ( "Fbx prefab update: " + message ) ;
53
+ }
54
+
55
+ [ System . Diagnostics . Conditional ( "FBXEXPORTER_DEBUG" ) ]
56
+ public static void Log ( string format , params object [ ] p ) {
57
+ Log ( string . Format ( format , p ) ) ;
58
+ }
59
+
47
60
/// <summary>
48
61
/// Utility function: create the object, which must be null.
49
62
/// </summary>
50
- /// <param name="item">Item.</param>
51
- /// <typeparam name="T">The 1st type parameter.</typeparam>
52
63
public static void Initialize < T > ( ref T item ) where T : new ( )
53
64
{
54
65
if ( item != null ) { throw new FbxPrefabException ( ) ; }
@@ -577,7 +588,6 @@ void ClassifyComponents(Transform newFbx)
577
588
builder . AppendFormat ( "\t {0}:{1}\n " , name , typename ) ;
578
589
Append ( ref components , name , typename , component ) ;
579
590
}
580
- Debug . Log ( "Component map:\n " + builder . ToString ( ) ) ;
581
591
582
592
// What's the logic?
583
593
// First check if a component is present or absent. It's
@@ -623,9 +633,6 @@ void ClassifyComponents(Transform newFbx)
623
633
var newValues = m_new . GetComponentValues ( name , typename ) ;
624
634
var prefabValues = m_prefab . GetComponentValues ( name , typename ) ;
625
635
626
- Debug . Log ( string . Format ( "{4} - type {0}: {1} old / {2} new / {3} prefab" ,
627
- typename , oldValues . Count , newValues . Count , prefabValues . Count , name ) ) ;
628
-
629
636
// TODO: handle multiplicity! The algorithm is eluding me right now...
630
637
// We'll need to do some kind of 3-way matching.
631
638
if ( oldValues . Count > 1 ) { Debug . LogError ( "TODO: handle multiplicity " + oldValues . Count ) ; }
@@ -649,7 +656,6 @@ void ClassifyComponents(Transform newFbx)
649
656
// if oldValue != prefabValue, conflict =>
650
657
// resolve in favor of Chris, so update
651
658
// anyway.
652
- Debug . Log ( string . Format ( "{0}\n {1}\n Differ" , oldValue , newValue ) ) ;
653
659
Append ( ref typesToUpdate , typename ) ;
654
660
}
655
661
}
@@ -738,7 +744,7 @@ public void ImplementUpdates(FbxPrefab prefabInstance)
738
744
// Create new nodes.
739
745
foreach ( var name in m_nodesToCreate ) {
740
746
prefabNodes . Add ( name , new GameObject ( name ) . transform ) ;
741
- Debug . Log ( name + ": Created" ) ;
747
+ Log ( "{0}: created new GameObject" , name ) ;
742
748
}
743
749
744
750
// Implement the reparenting in two phases to avoid making loops, e.g.
@@ -762,13 +768,13 @@ public void ImplementUpdates(FbxPrefab prefabInstance)
762
768
parentNode = prefabNodes [ parent ] ;
763
769
}
764
770
prefabNodes [ name ] . parent = parentNode ;
765
- Debug . Log ( name + ": Changed parent to " + parentNode . name ) ;
771
+ Log ( "changed {0} parent to {1}" , name , parentNode . name ) ;
766
772
}
767
773
768
774
// Destroy the old nodes.
769
775
foreach ( var toDestroy in m_nodesToDestroy ) {
770
776
GameObject . DestroyImmediate ( prefabNodes [ toDestroy ] . gameObject ) ;
771
- Debug . Log ( toDestroy + ": Destroyed" ) ;
777
+ Log ( "destroyed {0}" , toDestroy ) ;
772
778
}
773
779
774
780
// Destroy the old components.
@@ -781,7 +787,7 @@ public void ImplementUpdates(FbxPrefab prefabInstance)
781
787
var component = xfo . GetComponent ( componentType ) ;
782
788
if ( component != null ) {
783
789
Object . DestroyImmediate ( component ) ;
784
- Debug . Log ( name + ": Destroyed obsolete component " + componentType ) ;
790
+ Log ( "destroyed component {0}:{1}" , xfo . name , componentType ) ;
785
791
}
786
792
}
787
793
}
@@ -806,14 +812,14 @@ public void ImplementUpdates(FbxPrefab prefabInstance)
806
812
// Now update it.
807
813
if ( UnityEditorInternal . ComponentUtility . CopyComponent ( fbxComponent ) ) {
808
814
UnityEditorInternal . ComponentUtility . PasteComponentValues ( prefabComponent ) ;
809
- Debug . Log ( name + ": updated component " + fbxComponent . GetType ( ) ) ;
815
+ Log ( " updated component {0}:{1}" , name , fbxComponent . GetType ( ) ) ;
810
816
811
817
}
812
818
} else {
813
819
// We didn't find a match, so create the component as new.
814
820
if ( UnityEditorInternal . ComponentUtility . CopyComponent ( fbxComponent ) ) {
815
821
UnityEditorInternal . ComponentUtility . PasteComponentAsNew ( prefabXfo . gameObject ) ;
816
- Debug . Log ( name + ": added component " + fbxComponent . GetType ( ) ) ;
822
+ Log ( " added new component {0}:{1}" , name , fbxComponent . GetType ( ) ) ;
817
823
}
818
824
}
819
825
}
0 commit comments