• 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 ElChileVengador · Jun 26, 2021 at 01:59 PM · scripting beginner

Can't reference my script in an imported script

Hi all!

I'm sure this is a dumb question with a simple answer, but I'm having trouble accessing my own scripts from an imported script and I'm not sure why. My scripts are refered to correctly from other parts of the code, but I seem to be missing something in this one. The code I am referring is a simple monobehaviour with a static instance:

 using BansheeGz.BGDatabase;
 using Michsky.UI.Hexart;
 using System.Collections;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.Video;
 
 public class V4_SettingsManager : MonoBehaviour
 {
     /********************************************************
      * This class allows us to hold and save player settings
      * *****************************************************/
     public static V4_SettingsManager instance;
 
 
     private float masterVolume { get; set; }
     private float musicVolume { get; set; }
     private float sfxVolume { get; set; }
 

     public Slider slider_masterVol, slider_musicVol, slider_sfxVol, slider_missionVol, slider_UIVol, slider_StingerVol;
     
     public HorizontalSelector languageSelector;
 
     public delegate void SettingsChanged();
     public static event SettingsChanged OnSettingsChanged;


While the code I want to refer it in is a simple UIElement from a plugin (I'm sharing only part of the code here to not step on any toes):

 using UnityEngine.UI;
 using UnityEngine.Events;
 using NaughtyAttributes;
 using BansheeGz.BGDatabase;
 
 namespace Michsky.UI.Hexart
 {
     public class HorizontalSelector : MonoBehaviour
     {
 
         public bool useLocalization;
         [ShowIf("useLocalization")]
         public string localizationSheet;
 
         private Text label;
         private Text labeHelper;
         private Animator selectorAnimator;
 
         [Header("SETTINGS")]
         private int index = 0;
         public int defaultIndex = 0;
 
         [Header("ELEMENTS")]
         public List<string> elements = new List<string>();
 
         [Header("EVENT")]
         public UnityEvent onValueChanged;
 
         void Start()
         { 
         }
 
         void TranslateElements()
         {
         }
 
         public void PreviousClick()
         {
         }
 
         public void ForwardClick()
         {
         }
 }

Concretley I want to reference the delegate of the settingsManager in the Horizontal Selector script, but it can't find it. Does anyone know what I'm missing?

In advance, thanks. Rafa

Comment
Add comment · Show 4
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 Hellium · Jun 26, 2021 at 02:41 PM 0
Share

You rarely want to change the source code of an external plugin. What do you want to achieve precisely?


Does the plugin contain any assembly definition file? (.asmdef)

avatar image ElChileVengador Hellium · Jun 26, 2021 at 08:49 PM 0
Share

Hi Hellium,

Thanks for the reply! I'm trying to get the horizontal selector to react to the OnSettingsChanged event. The reason is that settings controls the localization of the game and I want to make sure that the selector updates it's strings when the settings are changed.

It's a real simple, self-contained method if I could get them to talk to each other.

I checked my project for an asmdef file related to the plugin and did not find one. The plugin is mainly UI tools and assets (which in my $$anonymous$$d makes it weirder yet :S )

avatar image Hellium ElChileVengador · Jun 26, 2021 at 08:53 PM 0
Share

Why don't you call the HorizontalSelector's method you want from V4_SettingsManager when OnSettingsChanged is called?


Either you intrdoduce a dependency V4_SettingsManager → HorizontalSelector using the method I've described, or you introduce a dependency HorizontalSelector → V4_SettingsManager by trying to tweak the plugin, which is not a good idea IMO.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ElChileVengador · Jun 30, 2021 at 01:30 AM

I've discovered the answer to my question.

The issue was that the plugin's script was in a folder I created called 'Plugins'. I didn't know that this folder was reserved by Unity and all scripts inside it are automatically placed in a different assembly:

alt text

This assembly cannot reference regular Unity scripts as it is compiled first (hence the 'first pass').

The solution was then simply to move the plugin's script files out of the plugins folder and presto! all is good :D


devenv-wkkzh3gloe.png (5.4 kB)
Comment
Add comment · 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

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

174 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 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 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 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 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 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 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 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

Parameter Values going crazy in mechanim when using SetFloat overload dampTime 0 Answers

I need a health script. 0 Answers

I don't know why my script wont work 1 Answer

Why does the 'Edit Script' button not open any external editor? 2 Answers

2D Fighter AI 0 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