當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.MonoBehaviour類代碼示例

本文整理匯總了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);
		}
開發者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


注:本文中的UnityEngine.MonoBehaviour類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。