• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.MonoBehaviour类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.MonoBehaviour的典型用法代码示例。如果您正苦于以下问题:C# MonoBehaviour类的具体用法?C# MonoBehaviour怎么用?C# MonoBehaviour使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MonoBehaviour类属于UnityEngine命名空间,在下文中一共展示了MonoBehaviour类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
		}
开发者ID:kybird,项目名称:PhoenixProject,代码行数:7,代码来源:iTweenSimplePlayer.cs


示例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();
 }
开发者ID:Gege00,项目名称:spacepuppy-unity-framework,代码行数:7,代码来源:AutoNotificationManager.cs


示例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);
        }
开发者ID:mtsouris81,项目名称:building-heist,代码行数:7,代码来源:_extensions.cs


示例4: Initialize

 public void Initialize(MonoBehaviour parent)
 {
     foreach(Bullet.Action action in actions)
     {
         action.Initialize(parent);
     }
 }
开发者ID:james7132,项目名称:Hysteria,代码行数:7,代码来源:Tags.cs


示例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;
        }
开发者ID:XuTenTen,项目名称:MultiThreadComponent,代码行数:28,代码来源:ImageEffectHelper.cs


示例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();
        }
开发者ID:AresLee,项目名称:FarmerSimulator,代码行数:41,代码来源:ModalHelper.cs


示例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();
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:28,代码来源:AudioFilterGUI.cs


示例8: MarkCapturePhase

        public static IDisposable MarkCapturePhase(MonoBehaviour target)
        {
            Count++;
            return Observable.TimerFrame(AnimationSpeed * Count)
                .Subscribe(_ => target.GetComponent<Renderer>().material.color = Color.green);

        }
开发者ID:ClusterVR,项目名称:teleportation_for_vive,代码行数:7,代码来源:Sample14_PresenterBase.cs


示例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();
 }
开发者ID:flow38,项目名称:StrangeIoC-Hollywood-extension,代码行数:7,代码来源:HollywoodMVCSContext.cs


示例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);
 }
开发者ID:88dre88,项目名称:ProyectoU,代码行数:7,代码来源:PlayerSetupWizard.cs


示例11: StepControl

        public StepControl(MasterPlayer player, MonoBehaviour context)
        {
            m_player	= player;
            m_context	= context;

            m_context.StartCoroutine(UpdateCo());
        }
开发者ID:rebuilder17,项目名称:fsnengine,代码行数:7,代码来源:StepControl.cs


示例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;
		}
开发者ID:paveltimofeev,项目名称:GameJamFramework,代码行数:11,代码来源:UIUtilities.cs


示例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));
        }
开发者ID:deltaDNA,项目名称:unity-sdk,代码行数:35,代码来源:Engage.cs


示例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);
 }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:14,代码来源:RevertInfo.cs


示例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);
            }
        }
开发者ID:ChicK00o,项目名称:behaviour_inject,代码行数:25,代码来源:InjectorBehaviour.cs


示例16: MoveAlignmentFromRightToLeft

		public static void MoveAlignmentFromRightToLeft(MonoBehaviour component)
		{
			RectTransform rectTransform = component.GetComponent<RectTransform>();
			rectTransform.anchorMin = new Vector2(0f, 1f);
			rectTransform.anchorMax = new Vector2(0f, 1f);
			rectTransform.anchoredPosition = new Vector2(-rectTransform.anchoredPosition.x + rectTransform.rect.width, rectTransform.anchoredPosition.y);
		}
开发者ID:paveltimofeev,项目名称:GameJamFramework,代码行数:7,代码来源:UIUtilities.cs


示例17: DrawAudioFilterGUI

 public void DrawAudioFilterGUI(MonoBehaviour behaviour)
 {
     int customFilterChannelCount = AudioUtil.GetCustomFilterChannelCount(behaviour);
     if (customFilterChannelCount > 0)
     {
         if (this.dataOut == null)
         {
             this.dataOut = new EditorGUI.VUMeter.SmoothingData[customFilterChannelCount];
         }
         double num2 = ((double) AudioUtil.GetCustomFilterProcessTime(behaviour)) / 1000000.0;
         float r = ((float) num2) / ((((float) AudioSettings.outputSampleRate) / 1024f) / ((float) customFilterChannelCount));
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         GUILayout.Space(13f);
         GUILayout.BeginVertical(new GUILayoutOption[0]);
         EditorGUILayout.Space();
         for (int i = 0; i < customFilterChannelCount; i++)
         {
             GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.MinWidth(50f), GUILayout.Height(5f) };
             EditorGUILayout.VUMeterHorizontal(AudioUtil.GetCustomFilterMaxOut(behaviour, i), ref this.dataOut[i], optionArray1);
         }
         GUILayout.EndVertical();
         Color color = GUI.color;
         GUI.color = new Color(r, 1f - r, 0f, 1f);
         GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(40f), GUILayout.Height(20f) };
         GUILayout.Box(string.Format("{0:00.00}ms", num2), options);
         GUI.color = color;
         GUILayout.EndHorizontal();
         EditorGUILayout.Space();
         GUIView.current.Repaint();
     }
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:31,代码来源:AudioFilterGUI.cs


示例18: StrikingState

 public StrikingState(MonoBehaviour parent)
     : base(parent)
 {
     gameController = (PoolGameController)parent;
     cue = gameController.cue;
     cueBall = gameController.cueBall;
 }
开发者ID:QuigleyC,项目名称:LMSC_281_Unity3D_Pool_Project,代码行数:7,代码来源:StrikingState.cs


示例19: LogSession

        /// <summary>
        /// Logs a session and returns session information on success.
        /// </summary>
        public static void LogSession(MonoBehaviour mb, ClientArgs args, Guid userId, string detail, string revisionId, Action<Guid, string> onSuccess, Action<string> onFailure)
        {
            var data = new Dictionary<string, object>();
            data.Add("user_id", userId);
            data.Add("release_id", args.ReleaseId);
            // XXX (kasiu): Need to check if this is the right DateTime string to send. I THINK THIS IS WRONG BUT I DON'T GIVE A FOOBAR RIGHT NOW. FIXME WHEN THE SERVER SCREAMS.
            data.Add("client_time", DateTime.Now.ToString());
            data.Add("detail", detail);
            data.Add("library_revid", revisionId);

            // Processing to get session_id
            Action<string> callback = s => {
                var s2 = s.Replace("{", "").Replace("}", "").Replace("\"", "").Trim();
                var split = s2.Split(',');
                if (split.Length != 2) {
                    onFailure(string.Format("LogSession received ill-formatted JSON: {0}", s));
                }
                var sessionId = split[0].Split(':')[1].Trim();
                var sessionKey = split[1].Split(':')[1].Trim();

                onSuccess(new Guid(sessionId), sessionKey);
            };

            var newArgs = new ClientArgs(new Uri(args.BaseUri, "/api/session"), args);
            SendNonSessionRequest(mb, newArgs, data, callback, onFailure);
        }
开发者ID:edbutler,项目名称:papika-telemetry,代码行数:29,代码来源:UnityBackend.cs


示例20: CheckForTangoApplication

 /// <summary>
 /// Check for a usable tango application component in the scene. Draw warning if 
 /// one could not be found.
 /// 
 /// Should be called first before using any other TangoPrefabInspectorHelper function
 /// during a given frame, to determine if a valid TangoApplication reference exists
 /// with which to call other TangoPrefabInspectorHelper methods.
 /// </summary>
 /// <returns><c>true</c>, if a tango application on an active GameObject can be identified, 
 /// <c>false</c> otherwise.</returns>
 /// <param name="inspectedBehaviour">Prefab behavior that's being inspected.</param>
 /// <param name="tangoApplication">Prefab inspector's reference to Tango Application, or
 /// null if no Tango Application on an active GameObject can be identified.</param>
 public static bool CheckForTangoApplication(MonoBehaviour inspectedBehaviour,
                                             ref TangoApplication tangoApplication)
 {
     if (tangoApplication == null || !tangoApplication.gameObject.activeInHierarchy)
     {
         tangoApplication = GameObject.FindObjectOfType<TangoApplication>();
     }
     
     // Note: .isActiveAndEnabled is the appropriate thing to check here because all Register() 
     // calls on existing Tango prefabs are called in Start(), which won't occur until both the
     // behaviour is enabled and the game object it is attached to is active.
     // 
     // Conversely, if any of the tango prefabs called Register() in Awake(), the correct thing
     // to check against would be .gameObject.activeInHeirarchy, since Awake is called when the
     // game object it is attached to is active, regardless of whether the behaviour itself is
     // enabled.
     if (tangoApplication == null && inspectedBehaviour.isActiveAndEnabled)
     {
         EditorGUILayout.HelpBox("Could not find an active TangoApplication component in the scene.\n\n"
                                 + "Component will not function correctly if it cannot find "
                                 + "an active TangoApplication component at runtime.",
                                 MessageType.Warning);
         return false;
     }
     
     return tangoApplication != null;
 }
开发者ID:kyr7,项目名称:tango-examples-unity,代码行数:40,代码来源:TangoPrefabInspectorHelper.cs



注:本文中的UnityEngine.MonoBehaviour类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.NavMeshAgent类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.MeshRenderer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap