Quantcast
Channel: Questions in topic: "protection"
Viewing all articles
Browse latest Browse all 107

cant access variable due to its protection

$
0
0
i have to scripts one with the variable and one trying to access it i cant access it even though it is public here are the two scripts the variable is called buildingActive using System.Collections; using System.Collections.Generic; using UnityEngine; public class CardBoardFloor : MonoBehaviour { public static CardBoardFloor instace; public bool buildingActive; public float GroundY; public bool IsPlaced; public bool IsSnapped; public float MousePosX; public float MousePosY; void Start() { instace = this; } void Update () { //as long as not placed it will follow mouse and building is active if (!IsPlaced && !IsSnapped && !buildingActive) { BuildingManager.IsBuilding = true; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit2; if (Physics.Raycast(ray, out hit2)) this.transform.position = new Vector3(hit2.point.x, hit2.point.y, hit2.point.z); GroundY = hit2.point.y; } if (Input.GetMouseButtonDown(0)) { IsPlaced = true; BuildingManager.IsBuilding = false; } // release snap if (IsSnapped && !IsPlaced && Mathf.Abs(MousePosX - Input.GetAxis("Mouse X")) > .5f || Mathf.Abs(MousePosY - Input.GetAxis("Mouse Y")) > .5f) { IsSnapped = false; } } } using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class invetory : MonoBehaviour { public CursorLockMode wantedMode; public CharacterController charMotor; public GameObject Inventory; public GameObject Inv; public GameObject BuildingManager; public Transform CardBoardFloorIcon; Transform CardBoardFloorIconClone; public string InventoryOpen = "false"; // Use this for initialization void Start () { Inventory.SetActive (false); Inv = GameObject.Find("Canvas").transform.Find("Inventory").transform.Find("tans inv").gameObject; } // Update is called once per frame void Update () { Cursor.lockState = wantedMode; if (InventoryOpen == "false") { wantedMode = CursorLockMode.Locked; } if (InventoryOpen == "false" && Input.GetKeyDown (KeyCode.I)) { (GameObject.Find("Player").GetComponent("FirstPersonController") as MonoBehaviour).enabled = false; wantedMode = CursorLockMode.None; charMotor.enabled = false; Inventory.SetActive (true); BuildingManager.SetActive (false); CardBoardFloor.instace.buildingActive (true); InventoryOpen = "true"; Cursor.visible = true; Cursor.lockState = wantedMode; } else { if (InventoryOpen == "true" && Input.GetKeyDown (KeyCode.I)) { (GameObject.Find("Player").GetComponent("FirstPersonController") as MonoBehaviour).enabled = true; wantedMode = CursorLockMode.Locked; charMotor.enabled = true; Inventory.SetActive (false); BuildingManager.SetActive (true); CardBoardFloor.instace.buildingActive (false); InventoryOpen = "false"; Cursor.lockState = wantedMode; } } if (Input.GetKeyDown (KeyCode.Alpha1)) { CardBoardFloorIconClone = Instantiate (CardBoardFloorIcon) as Transform; CardBoardFloorIconClone.transform.SetParent (Inv.transform); } } }

Viewing all articles
Browse latest Browse all 107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>