public GameObject Add(string textureName, Func<bool> isEnabled = null, Action onClick = null)
    {
        GameObject go = new GameObject();
        UITexture buttonTexture = go.EnsureComponent<UITexture>();

        if (onClick != null)
        {
            DaemonButton button = go.EnsureComponent<DaemonButton>();
            UIButton buttonUI = go.EnsureComponent<UIButton>();
            buttonUI.disabledColor = disabledColor;
            BoxCollider buttonBoxCollider = go.EnsureComponent<BoxCollider>();
            if (isEnabled != null)
            {
                go.EnsureComponent<IsEnabled>().Predicate = isEnabled;
                bool enabled = isEnabled();
                buttonUI.isEnabled = enabled;
                //buttonBoxCollider.enabled = enabled;
            }
            buttonBoxCollider.isTrigger = true;
            buttonTexture.ResizeCollider();

            button.click += onClick;
        }

        buttonTexture.mainTexture = Resources.Load<Texture2D>("Textures/" + textureName);
        buttonTexture.autoResizeBoxCollider = true;
        buttonTexture.depth = 10;
        _gameObjects.Add(go);
        return go;
    }
Example #2
0
 // Use this for initialization
 void Start()
 {
     cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
     cube.transform.parent = this.gameObject.transform;
     cube.transform.localPosition = new Vector3(0, 3f, 0);
     cube.transform.localScale = new Vector3(1, .25f, 0f);
     cube.RemoveComponent<BoxCollider>();
     cube.GetComponent<MeshRenderer>().material.color = new Color(.6f, 0f, 0f, .5f);
     cube.GetComponent<MeshRenderer>().material.shader = Shader.Find("Transparent/Cutout/Soft Edge Unlit");
     cube.transform.localRotation = new Quaternion();
     cube.EnsureComponent<LookAtCamera>();
 }
    // Use this for initialization
    void Start()
    {
        this.transform.rotation = Random.rotation;

        if (Target == null)
            Target = GameObject.FindGameObjectWithTag("Player");

        TargetRotationHelper = new GameObject("RotationHelper");
        TargetRotationHelper.transform.parent = this.transform;
        TargetRotationHelper.EnsureComponent<lookatPlayer>();

        //this.EnsureComponent<ImpactDamage>().Damage = Damage;

        this.EnsureComponent<Rigidbody>();
        rigidbody.useGravity = false;
    }
    void Start()
    {
        GameObject outline = new GameObject();
        outline.transform.parent = this.gameObject.transform;
        outline.transform.localPosition = Vector3.zero;
        outline.name = Name;

        _sprite = outline.EnsureComponent<UISprite>();
        _sprite.atlas = Resources.Load<GameObject>("GUI/Atlas").GetComponent<UIAtlas>();
        _sprite.spriteName = "Radiance";
        _sprite.type = UISprite.Type.Filled;
        _sprite.fillDirection = UISprite.FillDirection.Radial360;
        _sprite.invert = Clockwise;
        _sprite.transform.localScale = new Vector3(1, 1, 1);
        _sprite.width = Diameter;
        _sprite.height = Diameter;
        _sprite.depth = Depth;
        _sprite.color = Color;

        _totalPerimeterPercentage = (DegreeEnd - DegreeStart) / 360f;
    }