Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by CManzione · Feb 23, 2016 at 02:22 PM · cs0103

CS 0103 UnityEditor does not exist in the current context

Need some help here. I'm using a point cloud viewer and Oculus Camera Rig.

I'm getting the following compiler error CS 0103 UnityEditor does not exist in the current context

Here is the code.

 using UnityEngine;
 using System.Collections;
 using System.IO;
 
 public class PointCloudManager : MonoBehaviour {
 
     // File
     public string dataPath;
     private string filename;
     public Material matVertex;
 
     // GUI
     private float progress = 0;
     private string guiText;
     private bool loaded = false;
 
     // PointCloud
     private GameObject pointCloud;
 
     public float scale = 1;
     public bool invertYZ = false;
     public bool forceReload = false;
 
     public int numPoints;
     public int numPointGroups;
     private int limitPoints = 65000;
 
     private Vector3[] points;
     private Color[] colors;
     private Vector3 minValue;
 
     
     void Start () {
         // Create Resources folder
         createFolders ();
 
         // Get Filename
         filename = Path.GetFileName(dataPath);
 
         loadScene ();
     }
 
 
 
     void loadScene(){
         // Check if the PointCloud was loaded previously
         if(!Directory.Exists (Application.dataPath + "/Resources/PointCloudMeshes/" + filename)){
             UnityEditor.AssetDatabase.CreateFolder ("Assets/Resources/PointCloudMeshes", filename);
             loadPointCloud ();
         } else if (forceReload){
             UnityEditor.FileUtil.DeleteFileOrDirectory(Application.dataPath + "/Resources/PointCloudMeshes/" + filename);
             UnityEditor.AssetDatabase.Refresh();
             UnityEditor.AssetDatabase.CreateFolder ("Assets/Resources/PointCloudMeshes", filename);
             loadPointCloud ();
         } else
             // Load stored PointCloud
             loadStoredMeshes();
     }
     
     
     void loadPointCloud(){
         // Check what file exists
         if (File.Exists (Application.dataPath + dataPath + ".off")) 
             // load off
             StartCoroutine ("loadOFF", dataPath + ".off");
         else 
             Debug.Log ("File '" + dataPath + "' could not be found"); 
         
     }
     
     // Load stored PointCloud
     void loadStoredMeshes(){
 
         Debug.Log ("Using previously loaded PointCloud: " + filename);
 
         GameObject pointGroup = Instantiate(Resources.Load ("PointCloudMeshes/" + filename)) as GameObject;
 
         loaded = true;
     }
     
     // Start Coroutine of reading the points from the OFF file and creating the meshes
     IEnumerator loadOFF(string dPath){
 
         // Read file
         StreamReader sr = new StreamReader (Application.dataPath + dPath);
         sr.ReadLine (); // OFF
         string[] buffer = sr.ReadLine ().Split(); // nPoints, nFaces
         
         numPoints = int.Parse (buffer[0]);
         points = new Vector3[numPoints];
         colors = new Color[numPoints];
         minValue = new Vector3();
         
         for (int i = 0; i< numPoints; i++){
             buffer = sr.ReadLine ().Split ();
 
             if (!invertYZ)
                 points[i] = new Vector3 (float.Parse (buffer[0])*scale, float.Parse (buffer[1])*scale,float.Parse (buffer[2])*scale) ;
             else
                 points[i] = new Vector3 (float.Parse (buffer[0])*scale, float.Parse (buffer[2])*scale,float.Parse (buffer[1])*scale) ;
             
             if (buffer.Length >= 5)
                 colors[i] = new Color (int.Parse (buffer[3])/255.0f,int.Parse (buffer[4])/255.0f,int.Parse (buffer[5])/255.0f);
             else
                 colors[i] = Color.cyan;
 
             // Relocate Points near the origin
             //calculateMin(points[i]);
 
             // GUI
             progress = i *1.0f/(numPoints-1)*1.0f;
             if (i%Mathf.FloorToInt(numPoints/20) == 0){
                 guiText=i.ToString() + " out of " + numPoints.ToString() + " loaded";
                 yield return null;
             }
         }
 
         
         // Instantiate Point Groups
         numPointGroups = Mathf.CeilToInt (numPoints*1.0f / limitPoints*1.0f);
 
         pointCloud = new GameObject (filename);
 
         for (int i = 0; i < numPointGroups-1; i ++) {
             InstantiateMesh (i, limitPoints);
             if (i%10==0){
                 guiText = i.ToString() + " out of " + numPointGroups.ToString() + " PointGroups loaded";
                 yield return null;
             }
         }
         InstantiateMesh (numPointGroups-1, numPoints- (numPointGroups-1) * limitPoints);
 
         //Store PointCloud
         UnityEditor.PrefabUtility.CreatePrefab ("Assets/Resources/PointCloudMeshes/" + filename + ".prefab", pointCloud);
 
         loaded = true;
     }
 
     
     void InstantiateMesh(int meshInd, int nPoints){
         // Create Mesh
         GameObject pointGroup = new GameObject (filename + meshInd);
         pointGroup.AddComponent<MeshFilter> ();
         pointGroup.AddComponent<MeshRenderer> ();
         pointGroup.GetComponent<Renderer>().material = matVertex;
 
         pointGroup.GetComponent<MeshFilter> ().mesh = CreateMesh (meshInd, nPoints, limitPoints);
         pointGroup.transform.parent = pointCloud.transform;
 
 
         // Store Mesh
         UnityEditor.AssetDatabase.CreateAsset(pointGroup.GetComponent<MeshFilter> ().mesh, "Assets/Resources/PointCloudMeshes/" + filename + @"/" + filename + meshInd + ".asset");
         UnityEditor.AssetDatabase.SaveAssets ();
         UnityEditor.AssetDatabase.Refresh();
     }
 
     Mesh CreateMesh(int id, int nPoints, int limitPoints){
         
         Mesh mesh = new Mesh ();
         
         Vector3[] myPoints = new Vector3[nPoints]; 
         int[] indecies = new int[nPoints];
         Color[] myColors = new Color[nPoints];
 
         for(int i=0;i<nPoints;++i) {
             myPoints[i] = points[id*limitPoints + i] - minValue;
             indecies[i] = i;
             myColors[i] = colors[id*limitPoints + i];
         }
 
 
         mesh.vertices = myPoints;
         mesh.colors = myColors;
         mesh.SetIndices(indecies, MeshTopology.Points,0);
         mesh.uv = new Vector2[nPoints];
         mesh.normals = new Vector3[nPoints];
 
 
         return mesh;
     }
 
     void calculateMin(Vector3 point){
         if (minValue.magnitude == 0)
             minValue = point;
 
 
         if (point.x < minValue.x)
             minValue.x = point.x;
         if (point.y < minValue.y)
             minValue.y = point.y;
         if (point.z < minValue.z)
             minValue.z = point.z;
     }
 
     void createFolders(){
         if(!Directory.Exists (Application.dataPath + "/Resources/"))
             UnityEditor.AssetDatabase.CreateFolder ("Assets", "Resources");
 
         if (!Directory.Exists (Application.dataPath + "/Resources/PointCloudMeshes/"))
             UnityEditor.AssetDatabase.CreateFolder ("Assets/Resources", "PointCloudMeshes");
     }
 
 
     void OnGUI(){
 
 
         if (!loaded){
             GUI.BeginGroup (new Rect(Screen.width/2-100, Screen.height/2, 400.0f, 20));
             GUI.Box (new Rect (0, 0, 200.0f, 20.0f), guiText);
             GUI.Box (new Rect (0, 0, progress*200.0f, 20), "");
             GUI.EndGroup ();
         }
     }
 
 }
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Everything in red using Monodevelop, why?? 0 Answers

Error CS0103 : Array name "does not exist" if I initialize it in Start function 1 Answer

compiler error CS0103 The name 'CheckedBox' does not exist in the current context 0 Answers

Error CS 0103 "Debug does not exist in the current context" 0 Answers

error CS0103: The name `renderer' does not exist in the current context 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges