Search Unity

How can I fix the errors on The type or namespace name `PostProcessing' does not exist ?

Discussion in 'Scripting' started by Chocolade, Dec 9, 2018.

  1. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    933
    I'm using Unity 2018.2.5f1 Personal(64)
    In the unity editor: Edit > Project Settings > Player > Configuration > Scripting Runtime Version: .NET 4.x Equivalent API Level .NET 4.x

    Visual Studio Community 2017 .net version 4.7

    I have 4 errors about the PostProcessing:



    I tried to delete both Cinemachine and PostProcessing packages in the editor and imported them again. But still getting this errors.

    In the visual studio for example:

    Code (csharp):
    1.  
    2. using UnityEngine.PostProcessing;
    3.  
    The PostProcessing is not exist.

    Screenshot of the two packages installed imported:



    Maybe I didn't imported/installed the right PostProcessing package ? I did: Windows > Package Manager > All > Post Processing 2.1.2
     
    Last edited: Dec 9, 2018
  2. alexeu

    alexeu

    Joined:
    Jan 24, 2016
    Posts:
    257
    try this
    Code (CSharp):
    1. using UnityEngine.Rendering.PostProcessing;
     
    Chocolade likes this.
  3. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    933
    Nope. I have already this line with the Rendering. The problem is the later in the code I have this line:

    Code (csharp):
    1.  
    2. public PostProcessingProfile postProcProf;
    3.  
    And PostProcessingProfile has nothing to do with the Rendering it's using the PostProcessing that is missing.
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
    I just imported the Post Processing 2.1.2 project into a clean project and looked at so called 'PostProcessingProfile'.

    PostProcessingNamespace.png

    I think alexeu is correct in saying the namespace is 'UnityEngine.Rendering.PostProcessing'.

    I think unity moved the namespace of PostProcessing a little while back. Make sure you remove anything that says 'UnityEngine.PostProcessing'. Noting that your error is saying that there is no PostProcessing namespace in UnityEngine... this means you still have 'using UnityEngine.PostProcessing' somewhere... or a direct class marker to the same mismatched namespace.

    ...

    In the same respect you could have also taken the moment to just test what alexeu said instead of just immediately being dismissive of it. The error says there's a namespace issue, I would guess that the namespace may have moved... that happens. And PostProcessing deals with rendering, so moving it to UnityEngine.Rendering is a reasonable place to have moved it.
     
    Chocolade and alexeu like this.
  5. alexeu

    alexeu

    Joined:
    Jan 24, 2016
    Posts:
    257
    nothing to do with the Rendering ????
     
    lordofduct likes this.
  6. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    933

    Sorry I wasn't close to pc until now.
    I'm sorry I didn't mean to harm or insult alexeu. I'm respecting any answer and any help.

    In the end after installed and uninstalled few times now I re installed again the Post Processing Stack from the store. ( I tried from the github tried another source nothing worked ). Tried this before but it didn't work not sure why it does now.

    But this is how the script is now:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System;
    5. using UnityEngine.PostProcessing;
    6.  
    7. [RequireComponent(typeof(Camera))]
    8.  
    9. public class StackDoFAutoFocus : MonoBehaviour
    10. {
    11.  
    12.     private GameObject doFFocusTarget;
    13.     private Vector3 lastDoFPoint;
    14.  
    15.     private PostProcessingProfile m_Profile;
    16.  
    17.     public DoFAFocusQuality focusQuality = StackDoFAutoFocus.DoFAFocusQuality.NORMAL;
    18.     public LayerMask hitLayer = 1;
    19.     public float maxDistance = 100.0f;
    20.     public bool interpolateFocus = false;
    21.     public float interpolationTime = 0.7f;
    22.  
    23.     public enum DoFAFocusQuality
    24.     {
    25.         NORMAL,
    26.         HIGH
    27.     }
    28.  
    29.     void Start()
    30.     {
    31.         doFFocusTarget = new GameObject("DoFFocusTarget");
    32.         var behaviour = GetComponent<PostProcessingBehaviour>();
    33.         m_Profile = behaviour.profile;
    34.     }
    35.  
    36.     void Update()
    37.     {
    38.  
    39.         // switch between Modes Test Focus every Frame
    40.         if (focusQuality == StackDoFAutoFocus.DoFAFocusQuality.HIGH)
    41.         {
    42.             Focus();
    43.         }
    44.  
    45.     }
    46.  
    47.     void FixedUpdate()
    48.     {
    49.         // switch between modes Test Focus like the Physicsupdate
    50.         if (focusQuality == StackDoFAutoFocus.DoFAFocusQuality.NORMAL)
    51.         {
    52.             Focus();
    53.         }
    54.     }
    55.  
    56.     IEnumerator InterpolateFocus(Vector3 targetPosition)
    57.     {
    58.  
    59.         Vector3 start = this.doFFocusTarget.transform.position;
    60.         Vector3 end = targetPosition;
    61.         float dTime = 0;
    62.  
    63.         // Debug.DrawLine(start, end, Color.green);
    64.         var depthOfField = m_Profile.depthOfField.settings;
    65.         while (dTime < 1)
    66.         {
    67.             yield return new WaitForEndOfFrame();
    68.             dTime += Time.deltaTime / this.interpolationTime;
    69.             this.doFFocusTarget.transform.position = Vector3.Lerp(start, end, dTime);
    70.             depthOfField.focusDistance = Vector3.Distance(doFFocusTarget.transform.position, transform.position);
    71.             m_Profile.depthOfField.settings = depthOfField;
    72.         }
    73.         this.doFFocusTarget.transform.position = end;
    74.     }
    75.  
    76.     void Focus()
    77.     {
    78.         // our ray
    79.         Ray ray = transform.GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
    80.         RaycastHit hit;
    81.         if (Physics.Raycast(ray, out hit, this.maxDistance, this.hitLayer))
    82.         {
    83.             Debug.DrawLine(ray.origin, hit.point);
    84.  
    85.             // do we have a new point?                  
    86.             if (this.lastDoFPoint == hit.point)
    87.             {
    88.                 return;
    89.                 // No, do nothing
    90.             }
    91.             else if (this.interpolateFocus)
    92.             { // Do we interpolate from last point to the new Focus Point ?
    93.               // stop the Coroutine
    94.                 StopCoroutine("InterpolateFocus");
    95.                 // start new Coroutine
    96.                 StartCoroutine(InterpolateFocus(hit.point));
    97.             }
    98.             else
    99.             {
    100.                 this.doFFocusTarget.transform.position = hit.point;
    101.                 var depthOfField = m_Profile.depthOfField.settings;
    102.                 depthOfField.focusDistance = Vector3.Distance(doFFocusTarget.transform.position, transform.position);
    103.                 // print(depthOfField.focusDistance);
    104.                 m_Profile.depthOfField.settings = depthOfField;
    105.             }
    106.             // asign the last hit
    107.             this.lastDoFPoint = hit.point;
    108.         }
    109.     }
    110. }
    111.  
    I'm not using the line:

    Code (csharp):
    1.  
    2. using UnityEngine.Rendering.PostProcessing;
    3.  
    But only the line:

    Code (csharp):
    1.  
    2. using UnityEngine.PostProcessing;
    3.  
    Can't tell why it's working now, I didn't change much.

    And sorry again I didn't mean to insult.
     
    Last edited: Dec 10, 2018
  7. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    933
    When I'm checking now I see that the PsotProcessingProfile is a script of the UnityEngine not the the Renderring part:

    Code (csharp):
    1.  
    2. using System;
    3.  
    4. namespace UnityEngine.PostProcessing
    5. {
    6.     public class PostProcessingProfile : ScriptableObject
    7.  
    If for testing I'm doing :

    Code (csharp):
    1.  
    2. UnityEngine.Rendering.PostProcessing.PostProcessProfile pf;
    3.  
    And then checking the PostProcessProfile I see a different script:

    Code (csharp):
    1.  
    2. #region Assembly Unity.Postprocessing.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    3. // D:\New Unity Projects\The Identity\Library\ScriptAssemblies\Unity.Postprocessing.Runtime.dll
    4. #endregion
    5.  
    6. using System;
    7. using System.Collections.Generic;
    8.  
    9. namespace UnityEngine.Rendering.PostProcessing
    10. {
    11.     public sealed class PostProcessProfile : ScriptableObject
    12.     {
    13.         [Tooltip("A list of all settings currently stored in this profile.")]
    14.         public List<PostProcessEffectSettings> settings;
    15.         public bool isDirty;
    16.  
    17.         public PostProcessProfile();
    18.  

    The first one is using PostProcessing the second PostProcessProfile.
    And the second one that use the Rendering don't have the property depthOfField

    On the line:

    Code (csharp):
    1.  
    2. var depthOfField = m_Profile.depthOfField.settings;
    3.  
     
  8. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
    Seems to me you've installed multiple different versions of it.

    And as I said... this library changed namespace over the years. So you probably have been swapping between versions that use different namespaces.
     
  9. joegrant

    joegrant

    Joined:
    Nov 1, 2015
    Posts:
    8
    I had the same issue. When updating the post processing package the reference to the old namespace broke. Because this caused a compile error within a script, the package would not install and compile correctly - therefore the namespace will never be recognised. Your "broken" script is preventing Unity from seeing the new namespace. You can test this by trying to add a normal post processing profile to a new camera - for me it wouldnt add.

    What I did to fix it was:
    • remove the post processing package.
    • Comment out the errors in any scripts that occur so I had no errors referring to PP.
    • Installed the post processing package again.
    • Uncommented the error lines.
    • Changed the namespace.

    Hope this helps.
     
  10. Mythran

    Mythran

    Joined:
    Feb 26, 2013
    Posts:
    85
    I know it's kinda late, just run into the same problem. But looking in here resolved it.
    It's no longer PostProcessingProfile now it's called PostProcessProfile and i guess Unity just stopped accepting deprecated code.
     
    SpatialQuotient and Shadowing like this.
  11. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Lol Thanks @Mythran this stomped me good.