本文整理汇总了C#中UnityEngine.MonoBehaviour类的典型用法代码示例。如果您正苦于以下问题:C# MonoBehaviour类的具体用法?C# MonoBehaviour怎么用?C# MonoBehaviour使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MonoBehaviour类属于UnityEngine命名空间,在下文中一共展示了MonoBehaviour类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Play
public void Play(MonoBehaviour owner, float delay, float time,
System.Action<float> whenUpdate,
System.Action<bool> whenFinish)
{
this.Play(owner, delay, time, false, iTweenSimple.LoopType.none,
whenUpdate, null, whenFinish);
}
示例2: AutoNotificationManager
public AutoNotificationManager(MonoBehaviour behaviour)
{
if (behaviour == null) throw new System.ArgumentNullException("behaviour");
_behaviour = behaviour;
_handlers = new Dictionary<System.Type, System.Delegate>();
this.Init();
}
示例3: HasSameTagAs
public static bool HasSameTagAs(this Collider source, MonoBehaviour self)
{
if (source == null || source.gameObject == null || source.gameObject.tag == null)
return false;
return source.gameObject.tag.Equals(self.gameObject.tag, StringComparison.OrdinalIgnoreCase);
}
示例4: Initialize
public void Initialize(MonoBehaviour parent)
{
foreach(Bullet.Action action in actions)
{
action.Initialize(parent);
}
}
示例5: IsSupported
public static bool IsSupported(Shader s, bool needDepth, bool needHdr, MonoBehaviour effect)
{
if (s == null || !s.isSupported)
{
Debug.LogWarningFormat("Missing shader for image effect {0}", effect);
return false;
}
if (!SystemInfo.supportsImageEffects || !SystemInfo.supportsRenderTextures)
{
Debug.LogWarningFormat("Image effects aren't supported on this device ({0})", effect);
return false;
}
if (needDepth && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
{
Debug.LogWarningFormat("Depth textures aren't supported on this device ({0})", effect);
return false;
}
if (needHdr && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
{
Debug.LogWarningFormat("Floating point textures aren't supported on this device ({0})", effect);
return false;
}
return true;
}
示例6: Open
/// <summary>
/// Create modal helper with the specified parent, sprite and color.
/// </summary>
/// <param name="parent">Parent.</param>
/// <param name="sprite">Sprite.</param>
/// <param name="color">Color.</param>
/// <returns>Modal helper index</returns>
public static int Open(MonoBehaviour parent, Sprite sprite = null, Color? color = null)
{
//проверить есть ли в кеше
if (!Templates.Exists(key))
{
Templates.FindTemplates();
CreateTemplate();
}
var modal = Templates.Instance(key);
modal.transform.SetParent(Utilites.FindCanvas(parent.transform), false);
modal.gameObject.SetActive(true);
modal.transform.SetAsLastSibling();
var rect = modal.GetComponent<RectTransform>();
rect.sizeDelta = new Vector2(0, 0);
rect.anchorMin = new Vector2(0, 0);
rect.anchorMax = new Vector2(1, 1);
rect.anchoredPosition = new Vector2(0, 0);
var img = modal.GetComponent<Image>();
if (sprite!=null)
{
img.sprite = sprite;
}
if (color!=null)
{
img.color = (Color)color;
}
used.Add(modal.GetInstanceID(), modal);
return modal.GetInstanceID();
}
示例7: DrawAudioFilterGUI
public void DrawAudioFilterGUI(MonoBehaviour behaviour)
{
int filterChannelCount = AudioUtil.GetCustomFilterChannelCount(behaviour);
if (filterChannelCount <= 0)
return;
if (this.dataOut == null)
this.dataOut = new EditorGUI.VUMeter.SmoothingData[filterChannelCount];
double num = (double) AudioUtil.GetCustomFilterProcessTime(behaviour) / 1000000.0;
float r = (float) num / ((float) AudioSettings.outputSampleRate / 1024f / (float) filterChannelCount);
GUILayout.BeginHorizontal();
GUILayout.Space(13f);
GUILayout.BeginVertical();
EditorGUILayout.Space();
for (int channel = 0; channel < filterChannelCount; ++channel)
EditorGUILayout.VUMeterHorizontal(AudioUtil.GetCustomFilterMaxOut(behaviour, channel), ref this.dataOut[channel], GUILayout.MinWidth(50f), GUILayout.Height(5f));
GUILayout.EndVertical();
Color color = GUI.color;
GUI.color = new Color(r, 1f - r, 0.0f, 1f);
GUILayout.Box(string.Format("{0:00.00}ms", (object) num), new GUILayoutOption[2]
{
GUILayout.MinWidth(40f),
GUILayout.Height(20f)
});
GUI.color = color;
GUILayout.EndHorizontal();
EditorGUILayout.Space();
GUIView.current.Repaint();
}
示例8: MarkCapturePhase
public static IDisposable MarkCapturePhase(MonoBehaviour target)
{
Count++;
return Observable.TimerFrame(AnimationSpeed * Count)
.Subscribe(_ => target.GetComponent<Renderer>().material.color = Color.green);
}
示例9: HollywoodMVCSContext
public HollywoodMVCSContext(MonoBehaviour view) : base(view, ContextStartupFlags.MANUAL_MAPPING)
{
_hollywoodContextView = view.GetComponent<IHollywoodContextView>();
if (_hollywoodContextView == null)
throw (new Exception("HollywoodMVCSContext constructor error, there's no IHollywoodContextView instance on context's view !!!"));
Start();
}
示例10: AddToActionList
private void AddToActionList(List<SetEnabledOnDialogueEvent.SetEnabledAction> actions, MonoBehaviour component, Toggle state)
{
SetEnabledOnDialogueEvent.SetEnabledAction newAction = new SetEnabledOnDialogueEvent.SetEnabledAction();
newAction.state = state;
newAction.target = component;
actions.Add(newAction);
}
示例11: StepControl
public StepControl(MasterPlayer player, MonoBehaviour context)
{
m_player = player;
m_context = context;
m_context.StartCoroutine(UpdateCo());
}
示例12: FlipXScale
/// <summary>
/// just sets the x scale to -x
/// </summary>
/// <param name="component"></param>
public static void FlipXScale(MonoBehaviour component)
{
RectTransform rectTransform = component.GetComponent<RectTransform>();
Vector3 scale = rectTransform.localScale;
scale.x *= -1f;
rectTransform.localScale = scale;
}
示例13: Request
internal static IEnumerator Request(MonoBehaviour caller, EngageRequest request, EngageResponse response)
{
string requestJSON = request.ToJSON();
string url = DDNA.Instance.ResolveEngageURL(requestJSON);
HttpRequest httpRequest = new HttpRequest(url);
httpRequest.HTTPMethod = HttpRequest.HTTPMethodType.POST;
httpRequest.HTTPBody = requestJSON;
httpRequest.TimeoutSeconds = DDNA.Instance.Settings.HttpRequestEngageTimeoutSeconds;
httpRequest.setHeader("Content-Type", "application/json");
System.Action<int, string, string> httpHandler = (statusCode, data, error) => {
string engagementKey = "DDSDK_ENGAGEMENT_" + request.DecisionPoint + "_" + request.Flavour;
if (error == null && statusCode >= 200 && statusCode < 300) {
try {
PlayerPrefs.SetString(engagementKey, data);
} catch (Exception exception) {
Logger.LogWarning("Unable to cache engagement: "+exception.Message);
}
} else {
Logger.LogDebug("Engagement failed with "+statusCode+" "+error);
if (PlayerPrefs.HasKey(engagementKey)) {
Logger.LogDebug("Using cached response");
data = "{\"isCachedResponse\":true," + PlayerPrefs.GetString(engagementKey).Substring(1);
} else {
data = "{}";
}
}
response(data, statusCode, error);
};
yield return caller.StartCoroutine(Network.SendRequest(httpRequest, httpHandler));
}
示例14: RevertInfo
/// <summary>
/// Set up a revert info for a static object.
/// </summary>
/// <param name="monoBehaviour">The MonoBehaviour that is making this RevertInfo.</param>
/// <param name="type">The type of the static object</param>
/// <param name="memberName">The member name of the field/property/method to be called on revert.</param>
/// <param name="value">The current value you want to save.</param>
public RevertInfo(MonoBehaviour monoBehaviour, Type type, string memberName, object value)
{
this.MonoBehaviour = monoBehaviour;
this.Type = type;
this.value = value;
this.MemberInfo = Type.GetMember(memberName);
}
示例15: ProcessBehaviour
private void ProcessBehaviour(MonoBehaviour behaviour)
{
Type componentType = behaviour.GetType();
ClassDataHolder data = ReflectionDataCache.GetClassData(componentType);
for (int i = 0; i < data.PropertyInfos.Length; i++)
{
PropertyInfo property = data.PropertyInfos[i];
if (data.PropertyAttributes[i]) continue;
ThrowIfNotNull(property.GetValue(behaviour, null));
object dependency = _context.Resolve(property.PropertyType);
property.SetValue(behaviour, dependency, null);
}
for (int i = 0; i < data.FieldInfos.Length; i++)
{
FieldInfo field = data.FieldInfos[i];
if (data.FieldAttributes[i]) continue;
ThrowIfNotNull(field.GetValue(behaviour));
object dependency = _context.Resolve(field.FieldType);
field.SetValue(behaviour, dependency);
}
}