Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Evan_B · Aug 12, 2013 at 10:38 PM · editoreditorwindow

2 Errors in script for the editor

I took this script from the Unity website to mess around with and copy pasted it and it is not working and gave me 2 errors (I dit not modify it).

 /// C# Example
 // Simple script that saves frames from the Game View when on play mode
 //
 // You can put later the frames togheter and create a video.
 // Note: The frames are saved next to the Assets folder.
 
 using UnityEngine;
 using UnityEditor;
 
 public class SimpleRecorder : EditorWindow {
     string fileName = "FileName";
 
     string status = "Idle";
     string recordButton = "Record";
     bool recording = false;
     float lastFrameTime = 0.0f;
     int capturedFrame = 0;
 
     [MenuItem ("Example/Simple Recorder")]
     static void Init () {
         SimpleRecorder window = 
             (SimpleRecorder)EditorWindow.GetWindow(typeof(SimpleRecorder));
     }
 
     void OnGUI () {
         fileName = EditorGUILayout.TextField ("File Name:", fileName);
         
         if(GUILayout.Button(recordButton)) {
             if(recording) { //recording
                 status = "Idle...";
                 recordButton = "Record";                
                 recording = false;
             } else { // idle
                 capturedFrame = 0;
                 recordButton = "Stop";
                 recording = true;
             }
         }
         EditorGUILayout.LabelField ("Status: ", status);
     }
     
     void Update () {
         if (recording) {
             if (EditorApplication.isPlaying && !EditorApplication.isPaused){
                 RecordImages();
                 Repaint();
             } else
                 status = "Waiting for Editor to Play";
         }
     }
     
     void RecordImages() {
         if(lastFrameTime < Time.time + (1/24f)) { // 24fps
             status = "Captured frame " + capturedFrame;
             Application.CaptureScreenshot(fileName + " " + capturedFrame + ".png");
             capturedFrame++;
             lastFrameTime = Time.time;    
         }
     }
 }

(source: http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow.Update.html)

the ERROS: Instance of SimpleRecorder couldn't be created because there is no script with that name. UnityEditor.EditorWindow:GetWindow(Type) SimpleRecorder:Init() (at Assets/Editor/BlackCoreEditorWindow.cs:16)

NullReferenceException: Object reference not set to an instance of an object UnityEditor.EditorWindow.GetWindow (System.Type t, Boolean utility, System.String title, Boolean focus) (at C:/BuildAgent/work/7535de4ca26c26ac/Editor/MonoGenerated/Editor/EditorWindow.cs:418) UnityEditor.EditorWindow.GetWindow (System.Type t) (at C:/BuildAgent/work/7535de4ca26c26ac/Editor/MonoGenerated/Editor/EditorWindow.cs:402) SimpleRecorder.Init () (at Assets/Editor/BlackCoreEditorWindow.cs:16)

How do I fix this?

Comment
Add comment · Show 1
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
avatar image noooodley · Aug 12, 2013 at 10:57 PM 0
Share

In the project view, is the relevant script also called SimpleRecorder?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by DaveA · Aug 12, 2013 at 10:57 PM

The first error tells me you didn't call the file SimpleRecorder.cs

Fix that and the second one will probably go away too.

Comment
Add comment · Show 1 · Share
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
avatar image Evan_B · Aug 12, 2013 at 11:01 PM 0
Share

Thank you.

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Find instance of EditorWindow without creating new one? 2 Answers

How can i get the center of the entire editor window 0 Answers

Editor window script only works when window is open? 1 Answer

Using System.Reflection for this code? 1 Answer


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