private bool IsValidScriptType(Type attemptedType, MonoScript attemptedScript)
        {
            if (attemptedType == null)
            {
                //user selected "None" when clicking the nipple.
                if (attemptedScript == null)
                {
                    return(true);
                }

                Debug.LogWarning("Unity can't find the type inside the script " + attemptedScript.name + "! Can't assign it!");
                return(false);
            }

            if (!requiredReferenceType.IsAssignableFrom(attemptedType))
            {
                Debug.LogWarningFormat("Cannot assign script {0} (containing the type {1}) to a {2}! The type of the script must derive from {3}!",
                                       attemptedScript.name, attemptedType, scriptReference.GetType().Name, requiredReferenceType.Name);
                return(false);
            }

            if (script == null)
            {
                return(true);
            }

            if (attemptedType != script.SystemType)
            {
                return(true);
            }

            return(false);
        }
        private void CacheScriptReferenceData(SerializedProperty property)
        {
            scriptReference = (ScriptReference_Base)SerializedPropertyHelper.GetTargetObjectOfProperty(property);

            requiredReferenceType = GetGenericScriptRestriction(scriptReference.GetType());

            script     = scriptReference.script;
            monoScript = null;
            if (script != null && script.SystemType != null)
            {
                typeToScript.TryGetValue(script.SystemType, out monoScript);
            }

            scriptreferenceCached = true;
        }
        private void FetchScriptReferenceData(SerializedProperty property)
        {
            scriptReference = (ScriptReference_Base)SerializedPropertyHelper.GetTargetObjectOfProperty(property);
            if (scriptReference == null)
            {
                return; //Happens when you first set an array or list's size to larger than 0.
            }
            requiredReferenceType = GetGenericScriptRestriction(scriptReference.GetType());

            script     = scriptReference.script;
            monoScript = null;
            if (script != null && script.SystemType != null)
            {
                typeToScript.TryGetValue(script.SystemType, out monoScript);
            }
        }