Ejemplo n.º 1
0
        public void AddPrefab()
        {
            SS_WallObjects[] newPrefabs = new SS_WallObjects[theWallPrefabs.Length + 1];

            for (int i = 0; i < theWallPrefabs.Length; i++)
            {
                newPrefabs[i] = theWallPrefabs[i];
            }

            newPrefabs[newPrefabs.Length - 1]           = new SS_WallObjects();
            newPrefabs[newPrefabs.Length - 1].thePrefab = SS_Common.SS_DefaultWallPrefab();
            theWallPrefabs = newPrefabs;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return the next prefab with all valid modifications applied
        /// </summary>
        /// <returns></returns>
        GameObject GetNextPrefab()
        {
            GameObject returnGO;

            if (theWallPrefabs.Length > 1)
            {
                switch (myDistrType)
                {
                case (DistributionType.Random):
                    currSequenceIndex = Random.Range(0, theWallPrefabs.Length);
                    returnGO          = UnityEditor.PrefabUtility.InstantiatePrefab(theWallPrefabs[currSequenceIndex].thePrefab as GameObject) as GameObject;
                    break;

                case (DistributionType.Sequence):
                    int theIndex = currSequenceIndex;
                    currSequenceIndex++;
                    if (currSequenceIndex == theWallPrefabs.Length)
                    {
                        currSequenceIndex = 0;
                    }
                    returnGO = UnityEditor.PrefabUtility.InstantiatePrefab(theWallPrefabs[theIndex].thePrefab as GameObject) as GameObject;
                    break;

                default:
                    returnGO = UnityEditor.PrefabUtility.InstantiatePrefab(theWallPrefabs[0].thePrefab as GameObject) as GameObject;
                    break;
                }
            }
            else
            {
                currSequenceIndex = 0;
                returnGO          = UnityEditor.PrefabUtility.InstantiatePrefab(theWallPrefabs[0].thePrefab as GameObject) as GameObject;
            }
            if (returnGO == null)
            {
                returnGO = SS_Common.SS_DefaultWallPrefab();
            }

            //Assign the parent
            returnGO.transform.SetParent(transform);

            //Assign the scale
            returnGO.transform.localScale = new Vector3(segmentScale, 1, segmentScale);


            return(returnGO);
        }