Hello,
Im taking a stab at setting up my first c# property but having some trouble.
Assets/Scripts/NodeScript/NodeTile.cs(26,18): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Could someone please educate on what Im going wrong here. Thanks in advance
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class NodeTile : NodeBase {
private NodeAttrActivePrefab _nodeAttrActivePrefab;
public NodeAttrActivePrefab nodeAttrActivePrefab{get {return _nodeAttrActivePrefab;}}
private NodeAttrPool _nodeAttrPool;
public NodeAttrPool nodeAttrPool{get {return _nodeAttrPool;}}
//
// Constructor running base class constuctor
public NodeTile(Vector3 worldPosition, int gridX, int gridY)
: base( worldPosition, gridX, gridY) {
//
// TEST Pooling
_nodeAttrPool.PoolObject = GameObject.Find ("Cube").name;
_nodeAttrPool.PoolGroup.NextPoolObj;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public struct NodeAttrPool {
private string _poolObject;
public string PoolObject
{
get
{ //
// Return from private
return _poolObject;
}
set {
//
// Set poolName
PoolName = value;
//
// Return to private
_poolObject = value;
}
}
private string _poolName;
public string PoolName
{
get
{ //
// Return from private
return _poolName;
}
set
{
//
// Create the GOPoolGroup
if (GameObject.Find (value + "Pool" ) == null) {
GameObject currentGoPoolGroup = new GameObject (value + "Pool");
Pool currentPoolGroup = currentGoPoolGroup.AddComponent<Pool> ();
currentPoolGroup.poolObj = GameObject.Find (value);
//
// Set PoolGroup
PoolGroup = currentPoolGroup;
}
//
// Return to private
_poolName = value + "Pool" ;
}
}
private Pool _poolGroup;
public Pool PoolGroup
{
get
{ //
// Return from private
return _poolGroup;
}
set
{ //
// Return to private
_poolGroup = value;
}
}
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Pool : MonoBehaviour {
public GameObject poolObj; // Object we want to pool
public List<GameObject> pooledObjects = new List<GameObject>(); // List of inactive pool objects
public GameObject NextPoolObj { // GameObject clone = pool.nextThing; triggers get{} & pool.nextThing = gameObject; triggers set{}
get {
//
// Check if we have any avaliabel pooled objects
if (pooledObjects.Count < 1){
//
// If not clone a new one
GameObject newClone = (GameObject)Instantiate (poolObj);
newClone.transform.parent = transform;
newClone.SetActive (false);
pooledObjects.Add (newClone);
//
// Add poolMember script componet to clone, the pool memeber
// calls pool.nextThing = gameObject; in void OnDisable() whitch
// fires off set{} and retuns obj to pool.
PoolMember poolMember = newClone.AddComponent<PoolMember>();
poolMember.pool = this;
}
//
// If we have an object avaliable in pooledObjects list set it to active, remove from pooledObjects and retun
GameObject clone = pooledObjects[0];
pooledObjects.RemoveAt (0);
clone.SetActive (true);
return clone;
}
set {
//
// Returns the object back to pooledObjects by calling pool.nextThing = gameObject; in void OnDisable()
value.SetActive (false);
pooledObjects.Add (value);
}
}
}