/*
     * 更新單位的所有部件的資料
     * 呼叫 UpdateAllGUIObjsOfGUIComponent()
     */
    private void UpdateUnitDataGUI( UnitData _UnitData , 
									GUIObjNameSet _ComponentGUIObjNames )
    {
        foreach( KeyValuePair<string, NamedObject> pair in _ComponentGUIObjNames.m_ObjMap )
        {
            string componentName = pair.Key ;

            if( false == _UnitData.componentMap.ContainsKey( componentName ) )
                continue ;
            GameObject GUIObj = pair.Value.Obj ;
            if( null == GUIObj )
                continue ;
            // Debug.Log( "componentName " + componentName ) ;
            UnitComponentData component = _UnitData.componentMap[ componentName ] ;
            UpdateAllGUIObjsOfGUIComponent( component , GUIObj ) ;

        }
    }
    /*
     * @brief Create GUI for unit data
     * 依照傳入的單位物件及樣本物件來創造一系列GUI物件
     * @param _TargetName the name of target unit
     * @param _PrefabName the prefab name of background object,
     * Template_GUI_SelectUnitDataBackground / Template_GUI_MainCharacterUnitDataBackground
     * @param _GUIBackgroundObjName the created background object name.
     * @param _GUIShieldSet the shield set of all GUI objects
     * @param _GUIWeaponSet the weapon set of all GUI objects
     */
    public void CreateUnitDataGUI( string _TargetName , 
								   string _PrefabName ,
								   ref string _GUIBackgroundObjName ,
								   ref GUIObjNameSet _GUIComponentObjSet )
    {
        // target infomation
        UnitData unitData = GlobalSingleton.GetUnitData( _TargetName ) ;
        if( null == unitData )
        {
            Debug.Log( "CreateUnitDataGUI() null == unitData _TargetName=" + _TargetName ) ;
            return ;
        }

        // create background object
        _GUIBackgroundObjName = ConstName.CreateGUIBackgroundObjName( _TargetName ) ;

        GameObject guiBackgroundObj = PrefabInstantiate.Create( _PrefabName , _GUIBackgroundObjName ) ;
        if( null == guiBackgroundObj )
            return ;

        // change texture for gui background object
        GUITexture guiTexture = guiBackgroundObj.GetComponentInChildren<GUITexture>() ;
        if( null == guiTexture )
            return ;

        // for assign correct background texture
        string ResourceName = unitData.m_UnitDataGUITextureName ;
        // Debug.Log( ResourceName ) ;

        Texture texture = ResourceLoad.LoadTexture( ResourceName ) ;
        if( null == texture )
        {
            Debug.Log( "CreateUnitDataGUI() : No such resource:" + ResourceName ) ;
            return ;
        }
        guiTexture.texture = texture ;

        // creating gui obj for each component
        string keyword ;
        _GUIComponentObjSet.m_ObjMap.Clear() ;
        string [] keys = new string[ unitData.componentMap.Count ];
        unitData.componentMap.Keys.CopyTo( keys , 0 ) ;

        // for all component
        // collect the name
        foreach( string componentName in keys )
        {
            if( -1 != componentName.IndexOf( "Shield" ) )
                keyword = "Shield" ;
            else if( -1 != componentName.IndexOf( "Sensor" ) )
                keyword = "Shield" ;
            else if( -1 != componentName.IndexOf( ConstName.UnitDataComponentImpulseEnginePrefix ) )
                keyword = "Shield" ;
            else if( -1 != componentName.IndexOf( "Weapon" ) )
                keyword = "Weapon" ;
            else
                continue ;

            UnitComponentData component = unitData.componentMap[ componentName ] ;

            string componentGUIObjName = ConstName.CreateGUIComponentObjectName( _TargetName ,
                                                                           	  componentName ) ;
            // Debug.Log( "componentObjName=" + componentObjName ) ;
            GameObject componentGUIObj = PrefabInstantiate.Create( "Template_GUI_Component_" + keyword ,
                                                                   componentGUIObjName ) ;

            if( null == componentGUIObj )
                continue ;

            // gui position from component param
            Rect guiRect = component.m_ComponentParam.GUIRect ;

            SetUnitDataGUITexture( componentGUIObj ,
                                   ConstName.UnitDataGUIComponentHP ,
                                   guiBackgroundObj.transform.localPosition.z ,
                                   0.0f ,
                                   guiRect ) ;

            SetUnitDataGUITexture( componentGUIObj ,
                                   ConstName.UnitDataGUIComponentReload ,
                                   guiBackgroundObj.transform.localPosition.z ,
                                   -5.0f ,
                                   guiRect ) ;

            SetUnitDataGUIText( componentGUIObj ,
                                component.m_ComponentParam.GUIDisplayName ,
                                ConstName.UnitDataGUIComponentLabel ,
                                guiBackgroundObj.transform.localPosition.z ,
                                guiRect ) ;

            if( null != guiBackgroundObj )
            {
                componentGUIObj.transform.parent = guiBackgroundObj.transform ;
            }

            _GUIComponentObjSet.m_ObjMap.Add( componentName , new NamedObject( componentGUIObjName ) ) ;
        }
        _GUIComponentObjSet.m_UnitName = _TargetName ;
        // Debug.Log( "_GUIComponentObjSet.m_UnitName=" + _TargetName ) ;
    }