private void SetAssets(AssetBundle assets, ScrewablePart.ScrewType screwType)
 {
     screwModelToUse = LoadScrewModelToUse(screwType, assets);
     screw_material  = assets.LoadAsset <Material>("Screw-Material.mat");
     screw_soundClip = (assets.LoadAsset("screwable_sound.wav") as AudioClip);
     clampModel      = (assets.LoadAsset("Tube_Clamp.prefab") as GameObject);
 }
Esempio n. 2
0
 /// <summary>
 /// The constructor
 /// </summary>
 /// <param name="position">The vector3 position</param>
 /// <param name="rotation">The vector3 rotation</param>
 /// <param name="scale">The scale applied to x y and z</param>
 /// <param name="size">The wrench size needed</param>
 /// <param name="type">The ScrewType enum</param>
 public Screw(Vector3 position, Vector3 rotation, float scale = 1, int size = 10, ScrewablePart.ScrewType type = ScrewablePart.ScrewType.Screw2)
 {
     this.position = position;
     this.rotation = rotation;
     this.scale    = scale;
     this.size     = size;
     this.type     = type;
 }
        private GameObject LoadScrewModelToUse(ScrewablePart.ScrewType screwType, AssetBundle assets)
        {
            switch (screwType)
            {
            case ScrewablePart.ScrewType.Nut:
                return(assets.LoadAsset("screwable_nut.prefab") as GameObject);

            case ScrewablePart.ScrewType.Screw1:
                return(assets.LoadAsset("screwable_screw1.prefab") as GameObject);

            case ScrewablePart.ScrewType.Screw2:
                return(assets.LoadAsset("screwable_screw2.prefab") as GameObject);

            case ScrewablePart.ScrewType.Screw3:
                return(assets.LoadAsset("screwable_screw3.prefab") as GameObject);

            default:
                return(assets.LoadAsset("screwable_nut.prefab") as GameObject);
            }
        }
        public ScrewablePart(SortedList <String, Screws> screwsListSave, AssetBundle screwsAssetBundle, GameObject parentGameObject, Vector3[] screwsPositionLocal, Vector3[] screwsRotationLocal, Vector3[] screwsScale = null, int screwsSizeForAll = 10, ScrewablePart.ScrewType screwType = ScrewablePart.ScrewType.Screw1)
        {
            SetAssets(screwsAssetBundle, screwType);
            InitHandDetection();

            this.parentGameObject = parentGameObject;

            screwsDefaultPositionLocal = screwsPositionLocal.Clone() as Vector3[];
            screwsDefaultRotationLocal = screwsRotationLocal.Clone() as Vector3[];

            LoadScrewsSave(screwsListSave, screwsDefaultPositionLocal, screwsDefaultRotationLocal, screwsSizeForAll);

            Vector3[] definedScrewScales = DefineScrewScales(screwsPositionLocal.Length, screwsScale);
            MakePartScrewable(this.screws, definedScrewScales);
        }