Ejemplo n.º 1
0
 public bool Equals(SerializableSystemType _Object)
 {
     if (_Object == null)
     {
         return(false);
     }
     return(SystemType.Equals(_Object.SystemType));
 }
Ejemplo n.º 2
0
        public override bool Equals(Object obj)
        {
            SerializableSystemType temp = obj as SerializableSystemType;

            if ((object)temp == null)
            {
                return(false);
            }
            return(Equals(temp));
        }
Ejemplo n.º 3
0
        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);
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (!monoScriptsCached)
            {
                CacheMonoScripts();
            }

            FetchScriptReferenceData(property);

            EditorGUI.BeginChangeCheck();
            var oldMonoScript = monoScript;

            monoScript = (MonoScript)EditorGUI.ObjectField(position, label, monoScript, typeof(MonoScript), false);
            if (EditorGUI.EndChangeCheck())
            {
                var systemType = monoScript == null ? null : monoScript.GetClass();

                if (IsValidScriptType(systemType, monoScript))
                {
                    script = systemType == null ? null : new SerializableSystemType(systemType);
                    scriptReference.script = script;

                    var targetObj = property.serializedObject.targetObject;
                    EditorUtility.SetDirty(targetObj);

                    var asGameObj = targetObj as GameObject;
                    if (asGameObj != null)
                    {
                        EditorSceneManager.MarkSceneDirty(asGameObj.scene);
                    }
                }
                else
                {
                    monoScript = oldMonoScript;
                }
            }
        }