protected override bool Init() { // make sure fake classes aren't defined if (!VCPluginSettings.NguiEnabled(gameObject)) { return(false); } if (!base.Init()) { return(false); } // we require a collider if (_collider == null) { VCUtils.DestroyWithError(gameObject, "No collider attached to colliderGameObject! Destroying this gameObject."); return(false); } _movingPartSprite = movingPart.GetComponent <UISprite>(); if (_movingPartSprite == null) { _movingPartSprite = movingPart.GetComponentInChildren <UISprite>(); } return(true); }
protected override bool Init() { if (!VCPluginSettings.EzguiEnabled(base.gameObject)) { return(false); } if (!base.Init()) { return(false); } if (this.colliderObject == this.movingPart) { LogSystem.LogWarning(new object[] { "VCAnalogJoystickEzgui may not behave properly when the colliderObject is the same as the movingPart! ", "You should add a Collider to a gameObject independent from the EZGUI UI components." }); } this._movingPartBehaviorComponent = this.GetEzguiBehavior(this.movingPart); if (this._movingPartBehaviorComponent == null) { VCUtils.DestroyWithError(base.gameObject, "Cannot find a SimpleSprite or UIButton component on movingPart. Destroying this control."); return(false); } if (this._collider == null) { VCUtils.DestroyWithError(base.gameObject, "No collider attached to colliderGameObject! Destroying this control."); return(false); } return(true); }
protected void InitGameObjects() { if (this.upStateObject == null && this.pressedStateObject == null) { LogSystem.LogWarning(new object[] { "No up or pressed state GameObjects specified! Setting upStateObject to this.gameObject." }); this.upStateObject = base.gameObject; } if (this.colliderObject == null) { GameObject arg_73_1; if ((arg_73_1 = this.upStateObject) == null) { arg_73_1 = (this.pressedStateObject ?? base.gameObject); } this.colliderObject = arg_73_1; } base.InitCollider(this.colliderObject); if (this._requireCollider && this._collider == null) { VCUtils.DestroyWithError(base.gameObject, "colliderObject must have a Collider component! Destroying this control."); return; } }
// initializes the object protected virtual bool Init() { // don't execute OnGUI behavior, for performance this.useGUILayout = false; #region error checking // make sure we have a VCTouchController if (VCTouchController.Instance == null) { Debug.LogWarning("Cannot find VCTouchController!\nVirtualControls requires a gameObject which has VCTouchController component attached in scene. Adding one for you..."); //gameObject.AddComponent<VCTouchController>(); VCUtils.AddTouchController(gameObject); } // make sure the movingPart is specified if (!movingPart) { VCUtils.DestroyWithError(gameObject, "movingPart is null, VCAnalogJoystick requires it to be assigned to a gameObject! Destroying this control."); return(false); } // make sure rangeX is positive if (this.RangeX <= 0.0f) { VCUtils.DestroyWithError(gameObject, "rangeMin must be less than rangeMax! Destroying this control."); return(false); } // make sure rangeY is positive if (this.RangeY <= 0.0f) { VCUtils.DestroyWithError(gameObject, "rangeMin must be less than rangeMax! Destroying this control."); return(false); } #endregion if (basePart == null) { basePart = this.gameObject; } if (colliderObject == null) { colliderObject = movingPart; } _deltaPixels = new Vector2(); _dragDeltaMagnitudeMaxSq = dragDeltaMagnitudeMaxPixels * dragDeltaMagnitudeMaxPixels; InitCollider(colliderObject); InitOriginValues(); TapCount = 0; AddInstance(); return(true); }
public static bool EzguiEnabled(GameObject go) { if (typeof(SpriteRoot).GetMember("fakeMember").Length == 0) { return(true); } VCUtils.DestroyWithError(go, "An EZGUI Virtual Control is being used, but EZGUI is not properly enabled!\nIn order to use EZGUI, open VCPluginSettings.cs and edit line 63 to #if false.\nSee that file for further instruction. Destroying this control."); return(false); }
void Start() { if (button == null) { // try to find it on this gameObject. button = gameObject.GetComponent <VCButtonBase>(); if (button == null) { VCUtils.DestroyWithError(gameObject, "You must specify a button for VCButtonPlaymakerUpdater to function. Destroying this object."); return; } } }
public static bool NguiEnabled(GameObject go) { if (typeof(UISprite).GetMember(VCPluginSettings.kFakeMemberName).Length == 0) { return(true); } VCUtils.DestroyWithError(go, "An NGUI Virtual Control is being used, but NGUI is not properly enabled!\n" + "In order to use NGUI, open VCPluginSettings.cs and edit line 82 to #if false.\n" + "See that file for further instruction. Destroying this control."); return(false); }
// not implemented as they aren't very popular, // uncomment here and in Update() if you want to use //public float magnitudeSqr; //public float angleRadians; //public float angleDegrees; #endregion void Start() { if (joystick == null) { // try to find it on this gameObject. joystick = gameObject.GetComponent <VCAnalogJoystickBase>(); if (joystick == null) { VCUtils.DestroyWithError(gameObject, "You must specify a joystick for VCAnalogJoystickPlaymakerUpdater to function. Destroying this object."); return; } } }
private void Awake() { base.useGUILayout = false; if (VCTouchController.Instance != null) { VCUtils.DestroyWithError(base.gameObject, "Only one VCTouchController can be in a scene! Destroying the gameObject with this component."); return; } VCTouchController.Instance = this; this.touches = new List <VCTouchWrapper>(); for (int i = 0; i < 5; i++) { this.touches.Add(new VCTouchWrapper()); } }
protected override bool Init() { this._requireCollider = false; if (!base.Init()) { return(false); } if (this._collider == null) { this._colliderGuiTexture = this.colliderObject.guiTexture; if (this._colliderGuiTexture == null) { VCUtils.DestroyWithError(base.gameObject, "There is no Collider attached to colliderObject, as well as no GUITexture, attach one or the other. Destroying this control."); return(false); } } return(true); }
private const int kEmulatedTouchFingerId = 99999; // the fingerId we assign to the TouchWrapper that represents Mouse input in the Editor. void Awake() { this.useGUILayout = false; if (Instance != null) { VCUtils.DestroyWithError(gameObject, "Only one VCTouchController can be in a scene! Destroying the gameObject with this component."); return; } Instance = this; touches = new List <VCTouchWrapper>(); // add a TouchWrapper for each touch we will track. We create // and reuse a pool instead of instantiating new touches during execution. for (int i = 0; i < kMaxTouches; i++) { touches.Add(new VCTouchWrapper()); } }
public static bool NguiEnabled(GameObject go) { #if UNITY_WP8 // Note: WP8 Metro doesn't support Type.GetMember(), and will error out during building. // We just assume EzguiEnabled in this case. return(true); #else if (typeof(UISprite).GetMember(VCPluginSettings.kFakeMemberName).Length == 0) { return(true); } VCUtils.DestroyWithError(go, "An NGUI Virtual Control is being used, but NGUI is not properly enabled!\n" + "In order to use NGUI, open VCPluginSettings.cs and edit line 82 to #if false.\n" + "See that file for further instruction. Destroying this control."); return(false); #endif }
protected virtual bool Init() { base.useGUILayout = false; if (VCTouchController.Instance == null) { LogSystem.LogWarning(new object[] { "Cannot find VCTouchController!\nVirtualControls requires a gameObject which has VCTouchController component attached in scene. Adding one for you..." }); VCUtils.AddTouchController(base.gameObject); } if (!this.movingPart) { VCUtils.DestroyWithError(base.gameObject, "movingPart is null, VCAnalogJoystick requires it to be assigned to a gameObject! Destroying this control."); return(false); } if (this.RangeX <= 0f) { VCUtils.DestroyWithError(base.gameObject, "rangeMin must be less than rangeMax! Destroying this control."); return(false); } if (this.RangeY <= 0f) { VCUtils.DestroyWithError(base.gameObject, "rangeMin must be less than rangeMax! Destroying this control."); return(false); } if (this.basePart == null) { this.basePart = base.gameObject; } if (this.colliderObject == null) { this.colliderObject = this.movingPart; } this._deltaPixels = Vector2.zero; this._dragDeltaMagnitudeMaxSq = this.dragDeltaMagnitudeMaxPixels * this.dragDeltaMagnitudeMaxPixels; base.InitCollider(this.colliderObject); this.InitOriginValues(); this.TapCount = 0; this.AddInstance(); return(true); }
protected void InitGameObjects() { if (upStateObject == null && pressedStateObject == null) { Debug.LogWarning("No up or pressed state GameObjects specified! Setting upStateObject to this.gameObject."); upStateObject = this.gameObject; } if (colliderObject == null) { // set colliderObject to the first non null GameObject in this order: colliderObject = upStateObject ?? pressedStateObject ?? this.gameObject; } InitCollider(colliderObject); if (_requireCollider && _collider == null) { VCUtils.DestroyWithError(this.gameObject, "colliderObject must have a Collider component! Destroying this control."); return; } }
protected override bool Init() { if (!VCPluginSettings.NguiEnabled(base.gameObject)) { return(false); } if (!base.Init()) { return(false); } if (this._collider == null) { VCUtils.DestroyWithError(base.gameObject, "No collider attached to colliderGameObject! Destroying this gameObject."); return(false); } this._movingPartSprite = this.movingPart.GetComponent <UISprite>(); if (this._movingPartSprite == null) { this._movingPartSprite = this.movingPart.GetComponentInChildren <UISprite>(); } return(true); }
protected override bool Init() { // we don't require a collider if the colliderObject has a guiTexture _requireCollider = false; if (!base.Init()) { return(false); } if (_collider == null) { // use the colliderObject's guiTexture for hit detection _colliderGuiTexture = colliderObject.GetComponent <GUITexture>(); if (_colliderGuiTexture == null) { VCUtils.DestroyWithError(gameObject, "There is no Collider attached to colliderObject, as well as no GUITexture, attach one or the other. Destroying this control."); return(false); } } return(true); }
protected override bool Init() { // make sure fake classes aren't defined if (!VCPluginSettings.EzguiEnabled(gameObject)) { return(false); } if (!base.Init()) { return(false); } if (colliderObject == movingPart) { // EZGUI hides controls by actually modifying their size and thusly their colliders, this will interfere // with collision detection behavior if the collider is on one of those objects. Debug.LogWarning("VCAnalogJoystickEzgui may not behave properly when the colliderObject is the same as the movingPart! " + "You should add a Collider to a gameObject independent from the EZGUI UI components."); } _movingPartBehaviorComponent = GetEzguiBehavior(movingPart); if (_movingPartBehaviorComponent == null) { VCUtils.DestroyWithError(gameObject, "Cannot find a SimpleSprite or UIButton component on movingPart. Destroying this control."); return(false); } if (_collider == null) { VCUtils.DestroyWithError(gameObject, "No collider attached to colliderGameObject! Destroying this control."); return(false); } return(true); }