public GameObject InstantiateMenuItemGO(Transform parent, MenuItemId menuItem, int index) { string menuName = string.Format(@"Menu/Menu_{0}_{1}", menuItem.GetHashCode(), index); GameObject prefab = LoadPrefabResource(menuName); if (prefab == null) { return(null); } GameObject obj = GameObject.Instantiate(prefab); obj.transform.parent = parent; obj.transform.localPosition = new Vector3(-1.2f, 0, -0.8f); obj.transform.localRotation = Quaternion.Euler(270, 90, 90); obj.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); var renderer = obj.GetComponentInChildren <MeshRenderer>(); renderer.sharedMaterial = MaterialDefault; var clr = renderer.sharedMaterial.color; renderer.sharedMaterial.color = new Color(clr.r, clr.g, clr.b, 1.0f); return(obj); }
public void Initialize(IGameInterface gameInterface, MenuItemId menuItemId, FDPosition position, FDPosition showUpPosition, bool enabled, bool selected) { this.gameInterface = gameInterface; this.gameObject.name = string.Format(@"menuitem_{0}", menuItemId.GetHashCode()); this.gameObject.transform.localPosition = FieldTransform.GetGroundPixelPosition(showUpPosition); Vector3 menuLocalPosition = FieldTransform.GetGroundPixelPosition(position); MenuSliding sliding = this.gameObject.AddComponent <MenuSliding>(); sliding.Initialize(menuLocalPosition); this.isEnabled = enabled; this.isSelected = selected; this.position = position; this.menuItemId = menuItemId; var box = this.gameObject.AddComponent <BoxCollider>(); box.size = new Vector3(2.4f, 0.2f, 2.4f); box.center = new Vector3(0f, 0.2f, 0f); }