Beispiel #1
0
        public void Prepare(PipelineResources.CameraRenderingPath renderingPath)
        {
            RequireEventAttribute requireEvt = GetType().GetCustomAttribute <RequireEventAttribute>(true);

            this.renderingPath = renderingPath;
            if (requireEvt != null)
            {
                if (dependingEvents == null)
                {
                    dependingEvents = new List <PipelineEvent>(requireEvt.events.Length);
                }
                foreach (var t in requireEvt.events)
                {
                    PipelineEvent targetevt = RenderPipeline.GetEvent(renderingPath, t);
                    if (targetevt != null)
                    {
                        if (targetevt.dependedEvents == null)
                        {
                            targetevt.dependedEvents = new List <PipelineEvent>();
                        }
                        targetevt.dependedEvents.Add(this);
                        dependingEvents.Add(targetevt);
                    }
                }
            }
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            PipelineEvent evt = serializedObject.targetObject as PipelineEvent;

            evt.Enabled = EditorGUILayout.Toggle("Enabled", evt.Enabled);
            EditorUtility.SetDirty(evt);
            base.OnInspectorGUI();
        }
 public static PipelineEvent[] GetAllEvents(Type[] types, Dictionary <Type, PipelineEvent> dict)
 {
     PipelineEvent[] events = new PipelineEvent[types.Length];
     for (int i = 0; i < events.Length; ++i)
     {
         events[i] = dict[types[i]];
     }
     return(events);
 }
Beispiel #4
0
 public static PipelineEvent[] GetAllEvents(object obj)
 {
     FieldInfo[]     infos     = obj.GetType().GetFields();
     PipelineEvent[] allEvents = new PipelineEvent[infos.Length];
     for (int i = 0; i < allEvents.Length; ++i)
     {
         allEvents[i] = infos[i].GetValue(obj) as PipelineEvent;
     }
     return(allEvents);
 }
Beispiel #5
0
 public PipelineEvent[] GetAllEvents()
 {
     FieldInfo[]     infos  = GetType().GetFields();
     PipelineEvent[] events = new PipelineEvent[infos.Length];
     for (int i = 0; i < events.Length; ++i)
     {
         events[i] = infos[i].GetValue(this) as PipelineEvent;
     }
     return(events);
 }
        public static void RemoveProperty <T>(PipelineCamera camera, PipelineEvent evt)
        {
            IPerCameraData data = camera.allDatas[evt];

            if (data != null)
            {
                data.DisposeProperty();
            }
            data = null;
        }
        public static IPerCameraData GetProperty(PipelineEvent targetEvent, PipelineCamera camera, Func <IPerCameraData> initFunc)
        {
            IPerCameraData data;

            if (!camera.postDatas.TryGetValue(targetEvent, out data))
            {
                data = initFunc();
                camera.postDatas.Add(targetEvent, data);
            }
            return(data);
        }
        public static T GetProperty <T>(PipelineCamera camera, Func <T> initFunc, PipelineEvent evt) where T : IPerCameraData
        {
            IPerCameraData data;

            if (!camera.allDatas.TryGetValue(evt, out data))
            {
                data = initFunc();
                camera.allDatas.Add(evt, data);
            }
            return((T)data);
        }
        public static T GetProperty <T, R>(PipelineCamera camera, R runnable, PipelineEvent evt) where T : IPerCameraData where R : IGetCameraData
        {
            IPerCameraData data;

            if (!camera.allDatas.TryGetValue(evt, out data))
            {
                data = runnable.Run();
                camera.allDatas.Add(evt, data);
            }
            return((T)data);
        }
Beispiel #10
0
        public static PipelineEvent GetEvent(Type type)
        {
            var events = current.resources.availiableEvents;

            for (int i = 0; i < events.Length; ++i)
            {
                PipelineEvent evt = events[i];
                if (evt.GetType() == type)
                {
                    return(evt);
                }
            }
            return(null);
        }
Beispiel #11
0
        public static T GetEvent <T>() where T : PipelineEvent
        {
            var events = current.resources.availiableEvents;

            for (int i = 0; i < events.Length; ++i)
            {
                PipelineEvent evt = events[i];
                if (evt.GetType() == typeof(T))
                {
                    return((T)evt);
                }
            }
            return(null);
        }
        public static T GetEvent <T>(PipelineResources.CameraRenderingPath path) where T : PipelineEvent
        {
            var allEvents = current.resources.renderingPaths;

            PipelineEvent[] events = allEvents[path];
            for (int i = 0; i < events.Length; ++i)
            {
                PipelineEvent evt = events[i];
                if (evt.GetType() == typeof(T))
                {
                    return((T)evt);
                }
            }
            return(null);
        }
        public static PipelineEvent GetEvent(PipelineResources.CameraRenderingPath path, Type targetType)
        {
            var allEvents = current.resources.renderingPaths;

            PipelineEvent[] events = allEvents[path];
            for (int i = 0; i < events.Length; ++i)
            {
                PipelineEvent evt = events[i];
                if (evt.GetType() == targetType)
                {
                    return(evt);
                }
            }
            return(null);
        }
        public void Prepare()
        {
            RequireEventAttribute requireEvt = GetType().GetCustomAttribute <RequireEventAttribute>(true);

            if (requireEvt != null)
            {
                foreach (var t in requireEvt.events)
                {
                    PipelineEvent targetevt = RenderPipeline.GetEvent(t);
                    if (targetevt != null)
                    {
                        targetevt.dependedEvents.Add(new UIntPtr(MUnsafeUtility.GetManagedPtr(this)));
                        dependingEvents.Add(new UIntPtr(MUnsafeUtility.GetManagedPtr(targetevt)));
                    }
                }
            }
        }
        public void InitEvent(PipelineResources resources)
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            Init(resources);

            if (enabled)
            {
                if (dependingEvents.isCreated)
                {
                    foreach (var i in dependingEvents)
                    {
                        PipelineEvent evt = MUnsafeUtility.GetObject <PipelineEvent>(i.ToPointer());
                        if (!evt.enabled)
                        {
                            Enabled = false;
                            return;
                        }
                    }
                }
            }
            else
            {
                if (dependedEvents.isCreated)
                {
                    foreach (var i in dependedEvents)
                    {
                        PipelineEvent evt = MUnsafeUtility.GetObject <PipelineEvent>(i.ToPointer());
                        evt.Enabled = false;
                    }
                }
            }
            if (Enabled)
            {
                OnEnable();
            }
            else
            {
                OnDisable();
            }
        }
 private void OnEnable()
 {
     targetObj = serializedObject.targetObject as PipelineEvent;
 }
 public void RemoveEventManually(PipelineEvent evt)
 {
     allEvents.Remove(evt);
     evt.DisposeEvent();
 }
 /// <summary>
 /// Add and remove Events Manually
 /// Probably cause unnecessary error, try to avoid calling this methods
 /// </summary>
 /// <param name="evt"></param>
 public void AddEventManually(PipelineEvent evt)
 {
     allEvents.Add(evt);
     evt.InitEvent(resources);
 }