Exemplo n.º 1
0
        public void OnInitialize()
        {
            try
            {
                if (studio.view.rotationType == RotationType.Model)
                {
                    CameraHelper.LocateMainCameraToModel(model, studio);
                }

                ShadowHelper.LocateShadowToModel(model, studio);

                if (studio.shadow.type == ShadowType.Simple)
                {
                    ShadowHelper.ScaleSimpleShadow(model, studio);
                }
                else if (studio.shadow.type == ShadowType.TopDown)
                {
                    Camera     camera;
                    GameObject fieldObj;
                    ShadowHelper.GetCameraAndFieldObject(studio.shadow.obj, out camera, out fieldObj);

                    CameraHelper.LookAtModel(camera.transform, model);
                    ShadowHelper.ScaleShadowField(camera, fieldObj);
                }
                else if (studio.shadow.type == ShadowType.Matte)
                {
                    ShadowHelper.ScaleMatteField(meshModel, studio.shadow.obj, studio.lit);
                }

                if (studio.packing.on || studio.trimming.isUnifiedForAllViews)
                {
                    bakingDataList = new BakingData[studio.view.checkedSubViews.Count];
                }

                if (studio.trimming.isUnifiedForAllViews)
                {
                    unifiedTexBound = new IntegerBound();
                }

                fileBaseName = BuildFileBaseName();
                BuildFolderPathAndCreate(modelName);

                viewIndex = 0;

                stateMachine.ChangeState(BakingState.BeginView);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                Finish();
            }
        }
Exemplo n.º 2
0
        public void OnInitialize()
        {
            try
            {
                if (studio.view.rotationType == RotationType.Model)
                {
                    CameraHelper.LocateMainCameraToModel(model, studio);
                }

                ShadowHelper.LocateShadowToModel(model, studio);

                if (studio.shadow.type == ShadowType.TopDown)
                {
                    Camera     camera;
                    GameObject fieldObj;
                    ShadowHelper.GetCameraAndFieldObject(studio.shadow.obj, out camera, out fieldObj);

                    CameraHelper.LookAtModel(camera.transform, model);
                    ShadowHelper.ScaleShadowField(camera, fieldObj);
                }
                else if (studio.shadow.type == ShadowType.Matte)
                {
                    ShadowHelper.ScaleMatteField(meshModel, studio.shadow.obj, studio.lit);
                }

                fileNameForModel = BuildFileBaseName();
                BuildFolderPathAndCreate(modelName);

                if (studio.packing.on)
                {
                    if (DoesMakePrefab())
                    {
                        outRootPrefab = PrefabUtility.InstantiatePrefab(model.spritePrefab) as GameObject;
                        outRootPrefab.gameObject.SetActive(false);

                        if (studio.output.DoesMakeLocationPrefab())
                        {
                            Location[] locations = model.GetComponentsInChildren <Location>();
                            if (locations.Length > 0)
                            {
                                locationMappings = new LocationMapping[locations.Length];
                                for (int i = 0; i < locations.Length; ++i)
                                {
                                    Location   loc    = locations[i];
                                    GameObject locObj = PrefabUtility.InstantiatePrefab(studio.output.locationSpritePrefab) as GameObject;
                                    locObj.transform.parent        = model.prefabBuilder.GetLocationsParent(outRootPrefab);
                                    locObj.transform.localPosition = Vector3.zero;
                                    locObj.transform.localRotation = Quaternion.identity;
                                    locObj.name        += "_" + loc.locationName;
                                    locationMappings[i] = new LocationMapping(loc, locObj);
                                }
                            }
                        }

                        if (outRootPrefab != null && studio.output.animatorControllerMake && studio.output.normalMapMake)
                        {
                            animationTextureDataList = new List <AnimationTextureData>();
                        }
                    }
                }

                AnimationIndex = 0;

                stateMachine.ChangeState(BakingState.BeginAnimation);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                Finish();
            }
        }