Example #1
0
        public virtual GUIContent GetPreviewTitle()
        {
            GUIContent guiContent = new GUIContent();

            if (m_Targets.Length == 1)
            {
                guiContent.text = target.name;
            }
            else
            {
                guiContent.text = m_Targets.Length + " ";
                if (NativeClassExtensionUtilities.ExtendsANativeType(target))
                {
                    guiContent.text += MonoScript.FromScriptedObject(target).GetClass().Name;
                }
                else
                {
                    guiContent.text += ObjectNames.NicifyVariableName(ObjectNames.GetClassName(target));
                }

                guiContent.text += "s";
            }

            return(guiContent);
        }
Example #2
0
        private static string GetObjectTypeName([NotNull] Object o)
        {
            if (o is GameObject)
            {
                return(o.name);
            }

            // Show "Tags & Layers" instead of "TagManager"
            if (o is TagManager)
            {
                return("Tags & Layers");
            }

            if (o is Component)
            {
                var behaviour = o as MonoBehaviour;
                if (behaviour)
                {
                    var scriptClassName = behaviour.GetScriptClassName();
                    if (scriptClassName == "InvalidStateMachineBehaviour")
                    {
                        return(behaviour.name + L10n.Tr(" (Script)"));
                    }
                    return(scriptClassName + L10n.Tr(" (Script)"));
                }

                var meshfilter = o as MeshFilter;
                if (meshfilter)
                {
                    var mesh = meshfilter.sharedMesh;
                    return((mesh ? mesh.name : L10n.Tr("[none]")) + " (MeshFilter)");
                }

                return(o.GetType().Name);
            }

            // Importers don't have names. Just show the type without parenthesis (like we do for components).
            if (o is AssetImporter)
            {
                var monoImporter = o as MonoImporter;
                if (monoImporter)
                {
                    var script = monoImporter.GetScript();
                    return("Default References (" + (script ? script.name : string.Empty) + ")");
                }

                if (NativeClassExtensionUtilities.ExtendsANativeType(o))
                {
                    var script = MonoScript.FromScriptedObject(o);
                    if (script != null)
                    {
                        return(script.GetClass().Name + L10n.Tr(" (Script)"));
                    }
                }

                return(o.GetType().Name);
            }

            return(o.name + " (" + o.GetType().Name + ")");
        }
Example #3
0
        static bool HasValidScript(UnityEngine.Object obj)
        {
            MonoScript script = MonoScript.FromScriptedObject(obj);

            if (script == null)
            {
                return(false);
            }
            Type type = script.GetClass();

            if (type == null)
            {
                return(false);
            }
            return(true);
        }