コード例 #1
0
        public bool AddToList(OutlineTarget target)
        {
            bool result = false;
            OutlineTargetListKey key = new OutlineTargetListKey(target);

            if (!ContainsKey(key))
            {
                this[key] = new HashSet <OutlineTarget>();
            }

            result = this[key].Add(target);

            if (result)
            {
                modeCounter[(int)key.Mode]++;
                if (!thicknessCounter.ContainsKey(key.Thickness))
                {
                    thicknessCounter.Add(key.Thickness, 1);
                }
                else
                {
                    thicknessCounter[key.Thickness]++;
                }
                OutlinePostEffect.Add().enabled = true;
            }

            if (OnAdd != null)
            {
                OnAdd.Invoke(target);
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// adds outline post effect on a game object with camera component
        /// </summary>
        /// <param name="camera">an existing camera</param>
        /// <returns>a new outline post effect component if none was created before, the previous instantiated else</returns>
        public static OutlinePostEffect Add(Camera camera = null)
        {
            OutlinePostEffect result = null;

            if (Instance)
            {
                return(Instance);
            }

            if (camera == null)
            {
                camera = Camera.main;
            }

            if (!camera)
            {
                Debug.LogError("no main camera set in scene", Instance);
                return(result);
            }

            Instance          = camera.gameObject.AddComponent <OutlinePostEffect>();
            Instance.myCamera = camera;

            return(Instance);
        }