public static HUDToggleButton CreateToggleButton(HUDShape shape, float fHUDRadius, float fAngleHorz, float fAngleVert, string enabledIcon, string disabledIcon, IGameObjectGenerator addGeometry = null) { fMaterial enabledMat = MaterialUtil.CreateTransparentImageMaterialF(enabledIcon); fMaterial disabledMat = MaterialUtil.CreateTransparentImageMaterialF(disabledIcon); HUDToggleButton button = new HUDToggleButton() { Shape = shape }; button.Create(enabledMat); if (addGeometry != null) { button.AddVisualElements(addGeometry.Generate(), true); } HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert); button.OnToggled += (s, bEnabled) => { button.SetAllGOMaterials(bEnabled ? enabledMat : disabledMat); }; return(button); }
public HUDButton() { Shape = new HUDShape() { Type = HUDShapeType.Disc, Radius = 0.1f }; }
// creates a button with a floating primitive in front of the button shape public void Create(float fRadius, Material bgMaterial) { Shape = new HUDShape(HUDShapeType.Disc, fRadius); tempMaterial = MaterialUtil.ToUnityMaterial(Material); base.Create(PrimitiveType.Sphere, tempMaterial, 1.2f); ((GameObject)button).transform.localRotation = Quaternion.identity; }
public HUDPopupMessage() { Shape = new HUDShape() { Type = HUDShapeType.Disc, Radius = 0.1f }; }
public static HUDButton CreateDiscIconClickButton(float fButtonRadius, float fHUDRadius, float fAngleHorz, float fAngleVert, string icon, IGameObjectGenerator addGeometry = null) { HUDShape shape = new HUDShape(HUDShapeType.Disc, fButtonRadius); return(CreateIconClickButton(shape, fHUDRadius, fAngleHorz, fAngleVert, icon, addGeometry)); }
public HUDToggleButton() { Shape = new HUDShape(HUDShapeType.Disc, 0.1f); bChecked = true; TextHeight = 0.8f; TextColor = Colorf.Black; text = ""; }
public static HUDButton CreateRectIconClickButton(float fButtonWidth, float fButtonHeight, float fHUDRadius, float fAngleHorz, float fAngleVert, string icon, IGameObjectGenerator addGeometry = null) { HUDShape shape = new HUDShape(HUDShapeType.Rectangle, fButtonWidth, fButtonHeight); return(CreateIconClickButton(shape, fHUDRadius, fAngleHorz, fAngleVert, icon, addGeometry)); }
public HUDLabel() { Shape = new HUDShape(HUDShapeType.Rectangle, 10, 1); TextHeight = 0.8f; BackgroundColor = Colorf.VideoWhite; TextColor = Colorf.VideoBlack; DisabledTextColor = Colorf.DimGrey; AlignmentHorz = HorizontalAlignment.Left; text = "(default)"; }
public HUDLabel(float width, float height, ITextElementStyle textStyle) { Shape = new HUDShape(HUDShapeType.Rectangle, width, height); BackgroundColor = Colorf.TransparentBlack; BorderWidth = 0; BorderColor = Colorf.TransparentBlack; EnableBorder = false; TextHeight = textStyle.TextHeight; TextColor = textStyle.TextColor; AlignmentHorz = textStyle.AlignmentHorz; text = "(default)"; }
// creates a button in the desired geometry shape public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel")); bgMesh = AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape), MaterialUtil.CreateFlatMaterialF(BackgroundColor), entry); bgMesh.RotateD(Vector3f.AxisX, -90.0f); if (EnableBorder) { HUDShape borderShape = Shape; borderShape.Radius += BorderWidth; borderShape.Height += 2 * BorderWidth; borderShape.Width += 2 * BorderWidth; border = AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape), MaterialUtil.CreateFlatMaterialF(BorderColor), entry); border.RotateD(Vector3f.AxisX, -90.0f); border.Translate(-0.001f * Vector3f.AxisY, true); } BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); textMesh.TextObject.SetFixedWidth(Shape.Width); textMesh.TextObject.SetOverflowMode(TextOverflowMode.Ellipses); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); MaterialUtil.DisableShadows(RootGameObject); }
void update_shape(HUDShape newShape) { shape = newShape; if (bgMesh == null) { return; } bgMesh.SetSharedMesh( HUDUtil.MakeBackgroundMesh(shape)); if (EnableBorder) { HUDShape borderShape = shape; borderShape.Radius += BorderWidth; borderShape.Height += 2 * BorderWidth; borderShape.Width += 2 * BorderWidth; border.SetSharedMesh(HUDUtil.MakeBackgroundMesh(borderShape)); } }
public static HUDButton CreateIconClickButton(HUDShape shape, float fHUDRadius, float fAngleHorz, float fAngleVert, string icon, IGameObjectGenerator addGeometry = null) { Material mat = MaterialUtil.CreateTransparentImageMaterial(icon); HUDButton button = new HUDButton() { Shape = shape }; button.Create(mat); if (addGeometry != null) { button.AddVisualElements(addGeometry.Generate(), true); } HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert); return(button); }
public static HUDButton CreateGeometryIconClickButton(HUDShape shape, float fHUDRadius, float fAngleHorz, float fAngleVert, Color bgColor, IGameObjectGenerator addGeometry = null) { Material mat = (bgColor.a == 1.0f) ? MaterialUtil.CreateStandardMaterial(bgColor) : MaterialUtil.CreateTransparentMaterial(bgColor); HUDButton button = new HUDButton() { Shape = shape }; button.Create(mat); if (addGeometry != null) { button.AddVisualElements(addGeometry.Generate(), true); } HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert); return(button); }
// creates a button in the desired geometry shape public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDShapeElement")); bgMesh = new fGameObject(AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape), MaterialUtil.CreateFlatMaterialF(Color), entry)); bgMesh.RotateD(Vector3f.AxisX, -90.0f); if (EnableBorder) { HUDShape borderShape = Shape; borderShape.Radius += BorderWidth; borderShape.Height += 2 * BorderWidth; borderShape.Width += 2 * BorderWidth; border = new fGameObject(AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape), MaterialUtil.CreateFlatMaterialF(BorderColor), entry)); border.RotateD(Vector3f.AxisX, -90.0f); border.Translate(-0.001f * Vector3f.AxisY, true); } }
// creates a button with a floating primitive in front of the button shape public void CreateMeshIconButton(float fRadius, string sMeshPath, Material bgMaterial, float fMeshScaleFudge) { Shape = new HUDShape(HUDShapeType.Disc, fRadius); fMesh iconmesh = null; Material meshMaterial = null; try { iconmesh = FResources.LoadMesh(sMeshPath); meshMaterial = MaterialUtil.CreateStandardVertexColorMaterial(Color.white); } catch { } if (iconmesh == null) { iconmesh = UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere); meshMaterial = MaterialUtil.CreateStandardMaterial(Color.red); } float fMeshRadius = fRadius * fMeshScaleFudge; base.Create(bgMaterial, iconmesh, meshMaterial, fMeshRadius, Frame3f.Identity.Translated(-fMeshRadius * 0.25f, 2).Rotated(-15.0f, 1)); }
/// <summary> /// Create a fMesh of the shape/dimensions specified by Shape /// </summary> public static fMesh MakeBackgroundMesh(HUDShape Shape) { if (Shape.Type == HUDShapeType.Disc) { return(MeshGenerators.CreateTrivialDisc(Shape.Radius, Shape.Slices)); } else if (Shape.Type == HUDShapeType.Rectangle) { return(MeshGenerators.CreateTrivialRect(Shape.Width, Shape.Height, Shape.UseUVSubRegion == true ? MeshGenerators.UVRegionType.CenteredUVRectangle : MeshGenerators.UVRegionType.FullUVSquare)); } else if (Shape.Type == HUDShapeType.RoundRect) { return(MeshGenerators.CreateRoundRect(Shape.Width, Shape.Height, Shape.Radius, Shape.Slices, Shape.UseUVSubRegion == true ? MeshGenerators.UVRegionType.CenteredUVRectangle : MeshGenerators.UVRegionType.FullUVSquare, Shape.RoundRectSharpCorners)); } else { throw new Exception("HUDUtil.MakeBackgroundMesh: unknown shape type!"); } }
public HUDShapeElement() { Shape = new HUDShape(HUDShapeType.Rectangle, 10, 1); Color = Colorf.VideoWhite; }
public HUDButton() { Shape = new HUDShape(HUDShapeType.Disc, 0.1f); }
public HUDSpacer() { Shape = new HUDShape(HUDShapeType.Rectangle, 10, 1); }
// creates a button with a floating primitive in front of the button shape public void Create(float fRadius, Material bgMaterial) { Shape = new HUDShape(HUDShapeType.Disc, fRadius); base.Create(bgMaterial); }