• 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 Alanimator · Mar 16, 2014 at 01:50 AM · c#javascriptimage-effects

Unable to access any JS from within my C#

I am trying to acces the unity "image effects" scripts from withing my main c# script.

all Js scripts are inside my Assets/Plugins folder my C# script is inside my Assets/GameName/Stuff folder .

I have even tried placing the Js in the Standard Assets folder .

 using UnityEngine;  
 using System.Collections;  
    
 public class AccessJs : MonoBehaviour   
 {  
    
     private javaScript RefName;   
    
 
 }


how can I access the Js ? i'm confused , i'm sure that it should work but nothing I try does.

Comment
Add comment · Show 9
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 Sildaekar · Mar 16, 2014 at 01:53 AM 0
Share

What is "jsScript"? Is that a class?

Also, I think this link will help you out a lot more than any explanation here can.

avatar image Alanimator · Mar 16, 2014 at 02:00 AM 0
Share

yeah its a class . actually i'm thing an explanation here would suffice . i cant make heads or tails of that page . the syntax in C# used in other application development can be slightly different , sorting through all that would take too long.

avatar image Sildaekar · Mar 16, 2014 at 02:05 AM 0
Share

Actually the syntax won't change at all C# is C# no matter where you use it. And it will give you a basic understand of the language and syntax. Just go through the basic tutorials, as everything in them are used in Unity development.

Just start at basic syntax and continue from there.

Also, I noticed that you editor your question and changed it to "javaScript", but you said that "jsScript" was the class name. I'm confused, what is the exact code you are using to try to access the class you need?

avatar image Alanimator · Mar 16, 2014 at 02:10 AM 0
Share

i think you mean the logic stays the same throughout all c# but i'm sure the way the scripts are written varies across app development software.

umm this lnk here Accessing Js from C# and C# from Js

and it still does not work for me.

avatar image Sildaekar · Mar 16, 2014 at 02:13 AM 0
Share

Nope, I mean syntax (definition: a set of rules for or an analysis)

You access it the same way you would any other script, just treat it as if it were another C# script.

Show more comments

1 Reply

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

Answer by Sildaekar · Mar 16, 2014 at 02:36 AM

You access a Javascript (more appropriately known as UnityScript) script from a C# script just the same as if it were another C# script.

For example, if you want to use the AntialiasingAsPostEffect script (which is currently written in UnityScript) from a C# script you would do so as such:

 public AntialiasingAsPostEffect imageScript = new AntialiasingAsPostEffect();

The same as you would if it were a C# script.

Comment
Add comment · Show 4 · 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 Alanimator · Mar 16, 2014 at 04:23 AM 0
Share

this is the warning message that I get when I try that . "You are trying to create a $$anonymous$$onoBehaviour using the 'new' keyword. This is not allowed. $$anonymous$$onoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all"

none of the methods I have tried works. it is strange .

avatar image Alanimator · Mar 16, 2014 at 04:25 AM 0
Share

oh gosh .... its a bug. i was doing it correctly all along. your method will work without giving a warning if i revert it to the method I use.

i'm not too sure how bad the bug is but i will find out soon enough

avatar image Sildaekar · Mar 16, 2014 at 04:27 AM 0
Share

Yep...my bad...this is it:

 public AntialiasingAsPostEffect imageScript;
 
 
 public void Start(){
   imageScript=GameObject.Find("NA$$anonymous$$E OF GA$$anonymous$$EOBJECT").GetComponent<AntialiasingAsPostEffect>();
 }
avatar image Alanimator · Mar 16, 2014 at 05:09 AM 0
Share

i'm probably going to have to uninstall and re-install my version of unity . its the newest release too . I'm getting errors in monodevelop and no errors when compiling and running the script

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

22 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Need help converting Javascript to C# 3 Answers

How to Calling function in JS from C# 1 Answer

how to use matrice with unity 3D 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