Exemple #1
0
        public static DecoBuilder <TDeco> FromDeco <TDeco>(GameObject go, Asset asset) where TDeco : Deco
        {
            DecoBuilder <TDeco> builder = Parkitility.CreateDeco <TDeco>(go)
                                          .Id(asset.Guid)
                                          .DisplayName(asset.Name)
                                          .Price(asset.Price, false)
                                          .Category(asset.Category, asset.SubCategory)
                                          .SeeThrough(asset.SeeThrough)
                                          .BlockRain(asset.BlocksRain)
                                          .SnapGridToCenter(asset.SnapCenter)
                                          .GridSubdivisions(asset.GridSubdivision);

            if (asset.IsResizable)
            {
                builder.Resizable(asset.MinSize, asset.MaxSize);
            }
            if (asset.HasCustomColors)
            {
                builder.CustomColor(ConvertColors(asset.CustomColors));
            }
            foreach (var bound in ConvertBoundingBox(asset.BoundingBoxes.ToArray()))
            {
                builder.AddBoundingBox(bound);
            }

            return(builder);
        }
        public TResult Build(AssetManagerLoader loader)
        {
            GameObject go = UnityEngine.Object.Instantiate(_go);
            // existing Decos are not evaluated. Assumed to be configured correctly
            TResult vehicle = go.GetComponent <TResult>();

            if (vehicle == null)
            {
                vehicle = go.AddComponent <TResult>();
                if (!ContainsTag("GUID"))
                {
                    throw new Exception("Guid is never set");
                }
            }

            Apply(new BaseObjectContainer <TResult>(loader, vehicle, go));
            foreach (Renderer componentsInChild in go.GetComponentsInChildren <Renderer>())
            {
                Parkitility.ReplaceWithParkitectMaterial(componentsInChild);
            }

            List <Transform> transforms = new List <Transform>();

            Utility.recursiveFindTransformsStartingWith("WheelsFront", go.transform, transforms);
            vehicle.frontAxisArray = transforms.ToArray();
            transforms.Clear();
            Utility.recursiveFindTransformsStartingWith("WheelsBack", go.transform, transforms);
            vehicle.backAxisArray = transforms.ToArray();


            loader.RegisterObject(vehicle);

            return(vehicle);
        }
        public TResult Build(AssetManagerLoader loader)
        {
            GameObject go = UnityEngine.Object.Instantiate(_go);
            // existing Decos are not evaluated. Assumed to be configured correctly
            TResult deco = go.GetComponent <TResult>();

            if (deco == null)
            {
                deco = go.AddComponent <TResult>();
                if (!ContainsTag("GUID"))
                {
                    throw new Exception("Guid is never set");
                }
            }

            Apply(new BaseObjectContainer <TResult>(loader, deco, go));
            foreach (Renderer componentsInChild in go.GetComponentsInChildren <Renderer>())
            {
                Parkitility.ReplaceWithParkitectMaterial(componentsInChild);
            }

            // register deco
            loader.RegisterObject(deco);
            return(deco);
        }