protected void VerifySingletonOption <T>() where T : IService { Type t = typeof(T); ConstructionOption opt = constructionOption[t]; Assert.That(opt == ConstructionOption.AlwaysSingleton || opt == ConstructionOption.SingletonOrInstance, "The service " + GetName <T>() + " does not support singleton creation."); }
public GameObject CreateConstructionOption( string optionKey, Transform parent = null ) /* Create a display for one of the options of how to construct a component. * * :param string optionKey: What is this construction option called. * :param Transform parent: If supplied, make this object a child of `parent`. * * :returns GameObject constructionOptionObj: */ { GameObject constructionOptionObj = Instantiate( constructionOptionPrefab, Vector3.zero, Quaternion.identity ); ConstructionOption constructionOption = constructionOptionObj.GetComponent <ConstructionOption>(); constructionOption.optionKey = optionKey; // The construction option is a UI object, so make it a child of Canvas. parent = parent != null ? parent : canvasObj.transform; constructionOptionObj .GetComponent <RectTransform>() .transform.SetParent(parent); // Set position and size. Vector3 position = constructionOptionObj.GetComponent <RectTransform>().localPosition; position.z = 0; constructionOptionObj.GetComponent <RectTransform>().localPosition = position; constructionOptionObj.GetComponent <RectTransform>().localScale = Vector3.one; return(constructionOptionObj); }
/// <summary> /// construction option /// </summary> public void SelectConstructionOption() { ConstructionOption.Wait(3).Click(); }