Last active
January 12, 2018 22:02
-
-
Save michael-martinez/6b9b5f61f5a65d1b7fe1e990c9beed18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace Organization.Namespace | |
{ | |
/// <summary> | |
/// #SCRIPTNAME# class summary | |
/// </summary> | |
[RequireComponent(typeof(Collider))] | |
public class #SCRIPTNAME# : MonoBehaviour | |
{ | |
[TextArea] | |
public string Notes = "Some notes visible in the Inspector"; | |
private const string URL = "http://www.adress.com/"; | |
private Collider _collider = null; | |
#region Variables | |
public bool m_isActive = true; | |
public enum SampleEnum | |
{ | |
SampleValue, | |
_SIZE | |
} | |
public struct SampleStruct | |
{ | |
public int id; | |
public string field1; | |
public string field2; | |
} | |
/// <summary> | |
/// Sample Event | |
/// </summary> | |
public delegate void SampleEventRaised(); | |
public static event SampleEventRaised OnSampleEventRaised; | |
/// <summary> | |
/// External references | |
/// </summary> | |
//public ExternalScript S_ExternalScript = null; | |
#endregion | |
#region Init | |
void Awake() | |
{ | |
/*if (S_ExternalScript == null) | |
{ | |
Debug.LogWarning(" *** Warning : Please Assign External Scripts in the Inspector !"); | |
}*/ | |
_collider = GetComponent<Collider>(); | |
} | |
#endregion | |
#region Engine | |
void OnTriggerEnter(Collider other) | |
{ | |
if (other.gameObject.tag == "Player") | |
{ | |
} | |
} | |
void OnCollisionEnter(Collision other) | |
{ | |
if (other.gameObject.tag == "Player") | |
{ | |
} | |
} | |
#endregion | |
#region Interface | |
public void SampleMethod(int a_fuid) | |
{ | |
WWWForm form = new WWWForm(); | |
UTF8Encoding encoding = new System.Text.UTF8Encoding(); | |
form.AddField("uid", "" + a_fuid, encoding); | |
WWW www = new WWW(URL, form); | |
StartCoroutine(PostDataEnumerator(www)); | |
} | |
IEnumerator PostDataEnumerator(WWW www) | |
{ | |
yield return www; | |
if (!string.IsNullOrEmpty(www.error)) | |
{ | |
Debug.Log(" *** Error : " + www.error); | |
} | |
else | |
{ | |
string w_data = www.text; | |
Debug.Log("Data successfully submitted to server. Response { " + w_data + " }"); | |
} | |
} | |
private void _SamplePrivateMethod() | |
{ | |
} | |
#endregion | |
#region Debug | |
#if UNITY_EDITOR | |
void Update() | |
{ | |
if (Input.GetKeyUp("k")) | |
{ | |
SampleMethod(1); | |
} | |
if (Input.GetKeyUp("r")) | |
{ | |
OnSampleEventRaised += delegate () | |
{ | |
}; | |
OnSampleEventRaised(); | |
} | |
} | |
#endif | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment