Last active
March 6, 2018 21:20
-
-
Save fuzunspm/e46415c78d21dd437849ae0c30b734ea to your computer and use it in GitHub Desktop.
unity error on post processing addon
This file contains 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 System; | |
using System.Collections.Generic; | |
using UnityEditor; | |
namespace UnityStandardAssets.CrossPlatformInput.Inspector | |
{ | |
[InitializeOnLoad] | |
public class CrossPlatformInitialize | |
{ | |
// Custom compiler defines: | |
// | |
// CROSS_PLATFORM_INPUT : denotes that cross platform input package exists, so that other packages can use their CrossPlatformInput functions. | |
// EDITOR_MOBILE_INPUT : denotes that mobile input should be used in editor, if a mobile build target is selected. (i.e. using Unity Remote app). | |
// MOBILE_INPUT : denotes that mobile input should be used right now! | |
static CrossPlatformInitialize() | |
{ | |
var defines = GetDefinesList(buildTargetGroups[0]); | |
if (!defines.Contains("CROSS_PLATFORM_INPUT")) | |
{ | |
SetEnabled("CROSS_PLATFORM_INPUT", true, false); | |
SetEnabled("MOBILE_INPUT", true, true); | |
} | |
} | |
[MenuItem("Mobile Input/Enable")] | |
private static void Enable() | |
{ | |
SetEnabled("MOBILE_INPUT", true, true); | |
switch (EditorUserBuildSettings.activeBuildTarget) | |
{ | |
case BuildTarget.Android: | |
case BuildTarget.iOS: | |
case BuildTarget.WP8Player: | |
case BuildTarget.BlackBerry: | |
case BuildTarget.PSM: | |
case BuildTarget.Tizen: | |
case BuildTarget.WSAPlayer: | |
EditorUtility.DisplayDialog("Mobile Input", | |
"You have enabled Mobile Input. You'll need to use the Unity Remote app on a connected device to control your game in the Editor.", | |
"OK"); | |
break; | |
default: | |
EditorUtility.DisplayDialog("Mobile Input", | |
"You have enabled Mobile Input, but you have a non-mobile build target selected in your build settings. The mobile control rigs won't be active or visible on-screen until you switch the build target to a mobile platform.", | |
"OK"); | |
break; | |
} | |
} | |
[MenuItem("Mobile Input/Enable", true)] | |
private static bool EnableValidate() | |
{ | |
var defines = GetDefinesList(mobileBuildTargetGroups[0]); | |
return !defines.Contains("MOBILE_INPUT"); | |
} | |
[MenuItem("Mobile Input/Disable")] | |
private static void Disable() | |
{ | |
SetEnabled("MOBILE_INPUT", false, true); | |
switch (EditorUserBuildSettings.activeBuildTarget) | |
{ | |
case BuildTarget.Android: | |
case BuildTarget.iOS: | |
case BuildTarget.WP8Player: | |
case BuildTarget.BlackBerry: | |
EditorUtility.DisplayDialog("Mobile Input", | |
"You have disabled Mobile Input. Mobile control rigs won't be visible, and the Cross Platform Input functions will always return standalone controls.", | |
"OK"); | |
break; | |
} | |
} | |
[MenuItem("Mobile Input/Disable", true)] | |
private static bool DisableValidate() | |
{ | |
var defines = GetDefinesList(mobileBuildTargetGroups[0]); | |
return defines.Contains("MOBILE_INPUT"); | |
} | |
private static BuildTargetGroup[] buildTargetGroups = new BuildTargetGroup[] | |
{ | |
BuildTargetGroup.Standalone, | |
BuildTargetGroup.WebGL, | |
BuildTargetGroup.Android, | |
BuildTargetGroup.iOS, | |
BuildTargetGroup.WP8, | |
BuildTargetGroup.BlackBerry | |
}; | |
private static BuildTargetGroup[] mobileBuildTargetGroups = new BuildTargetGroup[] | |
{ | |
BuildTargetGroup.Android, | |
BuildTargetGroup.iOS, | |
BuildTargetGroup.WP8, | |
BuildTargetGroup.BlackBerry, | |
BuildTargetGroup.PSM, | |
BuildTargetGroup.Tizen, | |
BuildTargetGroup.WSA | |
}; | |
private static void SetEnabled(string defineName, bool enable, bool mobile) | |
{ | |
//Debug.Log("setting "+defineName+" to "+enable); | |
foreach (var group in mobile ? mobileBuildTargetGroups : buildTargetGroups) | |
{ | |
var defines = GetDefinesList(group); | |
if (enable) | |
{ | |
if (defines.Contains(defineName)) | |
{ | |
return; | |
} | |
defines.Add(defineName); | |
} | |
else | |
{ | |
if (!defines.Contains(defineName)) | |
{ | |
return; | |
} | |
while (defines.Contains(defineName)) | |
{ | |
defines.Remove(defineName); | |
} | |
} | |
string definesString = string.Join(";", defines.ToArray()); | |
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, definesString); | |
} | |
} | |
private static List<string> GetDefinesList(BuildTargetGroup group) | |
{ | |
return new List<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(group).Split(';')); | |
} | |
} | |
} |
This file contains 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 System; | |
using UnityEngine; | |
using System.Collections; | |
namespace UnityStandardAssets.Effects | |
{ | |
public class WaterHoseParticles : MonoBehaviour | |
{ | |
public static float lastSoundTime; | |
public float force = 1; | |
public Rigidbody attachedRigidbody; | |
private ParticleCollisionEvent[] m_CollisionEvents = new ParticleCollisionEvent[16]; | |
private ParticleSystem m_ParticleSystem; | |
private void Start() | |
{ | |
m_ParticleSystem = GetComponent<ParticleSystem>(); | |
} | |
private void OnParticleCollision(GameObject other) | |
{ | |
int safeLength = m_ParticleSystem.GetSafeCollisionEventSize(); | |
if (m_CollisionEvents.Length < safeLength) | |
{ | |
m_CollisionEvents = new ParticleCollisionEvent[safeLength]; | |
} | |
int numCollisionEvents = m_ParticleSystem.GetCollisionEvents(other, m_CollisionEvents); | |
int i = 0; | |
while (i < numCollisionEvents) | |
{ | |
if (Time.time > lastSoundTime + 0.2f) | |
{ | |
lastSoundTime = Time.time; | |
} | |
var Collider = m_CollisionEvents[i].colliderComponent; | |
if (GetComponent<Collider>().attachedRigidbody != null) | |
{ | |
Vector3 vel = m_CollisionEvents[i].velocity; | |
GetComponent<Collider>().attachedRigidbody.AddForce(vel*force, ForceMode.Impulse); | |
} | |
other.BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver); | |
i++; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment