Example #1
0
    /// <summary>
    /// 从数据库储存数据加载building
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public static Building Create(BuildingSaveData data)
    {
        Model model = LocalAssetUtil.GetModel(data.ModelDataId);

        if (model == null)
        {
            return(null);
        }
        GameObject obj = CreateGameObjcet(model, data.Name);

        ((TransformGroup)data.TransformGroupSaveData).Inject(obj.transform);
        Building building = AddComponentBuilding(obj.transform, model);

        if (data.MaterialColorSaveData != null)
        {
            Material material = MaterialUtil.Create();
            material.color    = (Color)data.MaterialColorSaveData;
            building.Material = material;
        }
        #region animation
        building.isAnimOn            = data.IsAnimOn;
        building.appearanceAnimDatas = AnimDataUtil.Parse(data.AppearanceAnimDataSaveDatas);
        building.normalAnimDatas     = AnimDataUtil.Parse(data.NormalAnimDataSaveDatas);
        #endregion
        return(building);
    }
Example #2
0
 public override void Open()
 {
     base.Open();
     //change by targetBuilding
     this.material = null;
     ChangeData(PanelControl.current.targetBuilding.Material.color);
     //init data
     this.material = MaterialUtil.Create();
     isFirstChange = true;
 }