本文整理汇总了C#中Problem.GetQuestion方法的典型用法代码示例。如果您正苦于以下问题:C# Problem.GetQuestion方法的具体用法?C# Problem.GetQuestion怎么用?C# Problem.GetQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Problem
的用法示例。
在下文中一共展示了Problem.GetQuestion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateRichTextAreas
private void PopulateRichTextAreas(Problem problemToDisplay)
{
Question question = problemToDisplay.GetQuestion ();
int textAreaCount = question.GetQuestionPartCount ();
float ySpacePerArea = 1f / (float)(textAreaCount - question.GetMultipleChoiceLetterCount());
float xSpacePerImage = (float)1/Mathf.Clamp((float)question.GetMaximumQuestionPartRepeated(), 1, imagesPerRow);
float ySpacePerImage = (float)1 / Mathf.Ceil((float)question.GetMaximumQuestionPartRepeated()
/ (float)imagesPerRow);
int row = 0;
bool previousAreaWasMultipleChoice = false;
if (textAreaCount == 0)
{
Senseix.Logger.BasicLog("I got a problem with no question atoms.");
return;//throw new UnityException ("I got a problem with no question atoms.");
}
richTextAreas = new GameObject[textAreaCount];
for (int i = 0; i < textAreaCount; i++)
{
GameObject newArea = Instantiate(questionTextPrefab) as GameObject;
ProblemPart problemPart = problemToDisplay.GetQuestion().GetQuestionPart(i);
if (newArea.GetComponent<RectTransform>() == null ||
newArea.GetComponent<Text>() == null )
throw new UnityException("richTextArea must have a rect transform and Text");
if (problemPart.HasString())
{
newArea.GetComponent<Text>().text += problemPart.GetString();
}
float indentedX = 0f;
if (previousAreaWasMultipleChoice)
indentedX = indentMultipleChoices;
newArea.GetComponent<RectTransform>().SetParent(questionParent);
PositionRectTransform(newArea.GetComponent<RectTransform>(),
indentedX,
1 - (row + 1) * ySpacePerArea,
1,
1 - row * ySpacePerArea);
if (problemPart.HasSprite())
{
//squish this a little bit to provide space between image groups
newArea.GetComponent<RectTransform>().anchorMin += new Vector2(0f, spaceImageAreas);
newArea.GetComponent<RectTransform>().anchorMax -= new Vector2(0f, spaceImageAreas);
for (int j = 0; j < problemPart.TimesRepeated(); j++)
{
GameObject newImage = Instantiate(questionImagePrefab) as GameObject;
newImage.GetComponent<RectTransform>().SetParent(newArea.transform);
int imageColumn = j % imagesPerRow;
int imageRow = Mathf.FloorToInt((float)j / (float)imagesPerRow);
PositionRectTransform(newImage.GetComponent<RectTransform>(),
(imageColumn * xSpacePerImage),
1 - (imageRow + 1) * ySpacePerImage,
((imageColumn + 1) * xSpacePerImage),
1 - imageRow * ySpacePerImage);
newImage.GetComponent<Image>().sprite = problemPart.GetSprite();
}
}
richTextAreas[i] = newArea;
if (!problemPart.IsMultipleChoiceLetter())
{
row++;
previousAreaWasMultipleChoice = false;
}
else
{
previousAreaWasMultipleChoice = true;
}
}
}