kOS.Suffixed.VectorRenderer.SetShow C# (CSharp) Method

SetShow() public method

public SetShow ( BooleanValue newShowVal ) : void
newShowVal kOS.Safe.Encapsulation.BooleanValue
return void
        public void SetShow(BooleanValue newShowVal)
        {
            if (newShowVal)
            {
                if (line == null || hat == null)
                {
                    lineObj = new GameObject("vecdrawLine");
                    hatObj = new GameObject("vecdrawHat");
                    labelObj = new GameObject("vecdrawLabel", typeof(GUIText));

                    line = lineObj.AddComponent<LineRenderer>();
                    hat = hatObj.AddComponent<LineRenderer>();
                    //TODO: 1.1 TODO
                    label = labelObj.GetComponent<GUIText>();

                    line.useWorldSpace = false;
                    hat.useWorldSpace = false;

                    GetShipCenterCoords();

                    line.material = new Material(Shader.Find("Particles/Additive"));
                    hat.material = new Material(Shader.Find("Particles/Additive"));

                    // This is how font loading would work if other fonts were available in KSP:
                    // Font lblFont = (Font)Resources.Load( "Arial", typeof(Font) );
                    // SafeHouse.Logger.Log( "lblFont is " + (lblFont == null ? "null" : "not null") );
                    // _label.font = lblFont;

                    label.text = labelStr;
                    label.anchor = TextAnchor.MiddleCenter;

                    PutAtShipRelativeCoords();
                    RenderValues();
                }
                updateHandler.AddObserver(this);
                line.enabled = true;
                hat.enabled = true;
                label.enabled = true;
            }
            else
            {
                updateHandler.RemoveObserver(this);
                if (label != null)
                {
                    label.enabled = false;
                    label = null;
                }
                if (hat != null)
                {
                    hat.enabled = false;
                    hat = null;
                }
                if (line != null)
                {
                    line.enabled = false;
                    line = null;
                }
                labelObj = null;
                hatObj = null;
                lineObj = null;
            }

            enable = newShowVal;
        }

Usage Example

Esempio n. 1
0
        public void DoExecuteWork(SharedObjects shared, Vector start, Vector vec, RgbaColor rgba, string str, double scale, bool show, double width)
        {
            var vRend = new VectorRenderer( shared.UpdateHandler, shared )
                {
                    Vector = vec,
                    Start = start,
                    Color = rgba,
                    Scale = scale,
                    Width = width
                };
            vRend.SetLabel( str );
            vRend.SetShow( show );

            ReturnValue = vRend;
        }
All Usage Examples Of kOS.Suffixed.VectorRenderer::SetShow