0
所以在这里我有一个图像将提供更好的理解我的问题。 因此,目前我有一些白色块,并在白色块内,我有一些青色边框。 所以我现在想解决的当前问题是。 每当白盒延伸到青色边框外时。我想调整它们的大小,使它们位于青色边框内。比如从顶端开始的五分之一。当它扩展了限制区域时调整gameObject的大小
我该如何解决这个问题?
在此先感谢。
编辑
void Update() {
if(numOfGeneratedGuideline < numOfGuidelineToGenerate) {
Generate_Guideline_Positons(numOfGeneratedGuideline);
Generate_Platform_Positions_And_Scale(numOfGeneratedGuideline);
Generate_Platforms(numOfGeneratedGuideline);
numOfGeneratedGuideline++;
}
}
void Generate_Guideline_Positons(int i) {
float tempGuidelineOffset = groundHeight + (guidelineOffset * (i + 1));
guidelinePosX[i] = worldWidth/2;
guidelinePosY[i] = tempGuidelineOffset;
guidelinePosZ[i] = 0;
}
void Generate_Platform_Positions_And_Scale(int i) {
randomGuidelineNumber = Random.Range(1, numOfGuidelineToGenerate + 1);
float tempPlatformPosXMin = (worldWidth - guidelineWidth)/2;
Debug.Log(tempPlatformPosXMin);
float tempPlatformPosXMax = worldWidth - tempPlatformPosXMin;
Debug.Log(tempPlatformPosXMax);
float tempPlatformPosY = groundHeight + (guidelineOffset * (i + 1));
platformPosX[i] = Random.Range(tempPlatformPosXMin, tempPlatformPosXMax);
platformPosY[i] = tempPlatformPosY;
platformPosZ[i] = 0;
platformScaleX[i] = Random.Range(minPlatformScaleRange, maxPlatformScaleRange);
platformScaleY[i] = 1;
platformScaleZ[i] = 1;
//22 29 36 43 50
}
void Generate_Platforms(int i) {
GameObject newplatform = Instantiate(platformPrefab, new Vector3(platformPosX[i], platformPosY[i], platformPosZ[i]), Quaternion.identity) as GameObject;
newplatform.transform.localScale = new Vector3(platformScaleX[i], platformScaleY[i], platformScaleZ[i]);
}
我认为生病给你提供了我的代码 – JekasG