public void GetAllAssetsDependency(Object[] objs)
    {
        Undo.RecordObject(m_CurrentlyEdited, "Dependencies added");
        if (m_CurrentlyEdited.dependenciesID == null)
        {
            m_CurrentlyEdited.dependenciesID = new string[0];
        }

        for (int i = 0; i < objs.Length; ++i)
        {
            string[] str = AssetDatabase.GetDependencies(AssetDatabase.GetAssetPath(objs[i]));

            for (int j = 0; j < str.Length; ++j)
            {
                string depID = AssetDatabase.AssetPathToGUID(str[j]);
                if (!ArrayUtility.Contains(m_CurrentlyEdited.dependenciesID, depID))
                {
                    ArrayUtility.Add(ref m_CurrentlyEdited.dependenciesID, depID);
                    ArrayUtility.Add(ref m_CurrentlyEdited.outputPath, AssetDatabase.GUIDToAssetPath(depID));
                }
            }
        }

        EditorUtility.SetDirty(m_CurrentlyEdited);

        PopulateTreeview();
    }
Ejemplo n.º 2
0
    public static void copyFile(string sourceDirectory, string destDirectory)
    {
        //获取所有文件名称
        Debug.Log("src file:" + sourceDirectory);
        string[] fileName = Directory.GetFiles(sourceDirectory);
        foreach (string filePath in fileName)
        {
            string ext = new FileInfo(filePath).Extension;
            if (!ArrayUtility.Contains(ResFileExt, ext))
            {
                continue;
            }

            //根据每个文件名称生成对应的目标文件名称
            string filePathTemp = destDirectory + "\\" + filePath.Substring(sourceDirectory.Length);

            Debug.Log("found file:" + filePath + " dest:" + filePathTemp);

            //若不存在,直接复制文件;若存在,覆盖复制
            if (File.Exists(filePathTemp))
            {
                File.Copy(filePath, filePathTemp, true);
            }
            else
            {
                File.Copy(filePath, filePathTemp);
            }
        }
    }
Ejemplo n.º 3
0
        private void SearchProject(Object selectedObject, bool isBulk = false)
        {
            results.Clear();

            // Find the path to the target file
            fileName = selectedObject.name;
            var t = fileName.Split('.');

            fileName   = t[0];
            targetPath = AssetDatabase.GetAssetPath(selectedObject);

            // Look at all prefabs or materials
            var searchType = searchMaterials ? "t:Material" : "t:Prefab";

            // Store file paths
            var allObjects = AssetDatabase.FindAssets(searchType);

            foreach (var thisObject in allObjects)
            {
                var temp = AssetDatabase.GUIDToAssetPath(thisObject);

                // Compare dependency
                var dependencies = AssetDatabase.GetDependencies(temp);
                if (ArrayUtility.Contains(dependencies, targetPath))
                {
                    results.Add(temp);
                }
            }

            showResults = true;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 判断是否依赖树变化了
        /// 如果现在的依赖和之前的依赖不一样了则改变了,需要重新打包
        /// </summary>
        public void AnalyzeIfDepTreeChanged()
        {
            _isDepTreeChanged = false;
            if (_cacheInfo != null)
            {
                HashSet <AssetTarget> deps = new HashSet <AssetTarget>();
                GetDependencies(deps);

                if (deps.Count != _cacheInfo.depNames.Length)
                {
                    _isDepTreeChanged = true;
                }
                else
                {
                    foreach (AssetTarget dep in deps)
                    {
                        if (!ArrayUtility.Contains <string>(_cacheInfo.depNames, dep.assetPath))
                        {
                            _isDepTreeChanged = true;
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void RemoveTagInEditor(Tag tag)
 {
     if (ArrayUtility.Contains(_tags, tag))
     {
         ArrayUtility.Remove(ref _tags, tag);
     }
 }
Ejemplo n.º 6
0
 public void AddTagInEditor(Tag tag)
 {
     if (!ArrayUtility.Contains(_tags, tag))
     {
         ArrayUtility.Add(ref _tags, tag);
     }
 }
Ejemplo n.º 7
0
        public static void FreeMoveBones(this SkeletonCache skeleton, BoneCache[] bones, Vector3 deltaPosition)
        {
            Debug.Assert(skeleton != null);

            foreach (var bone in bones)
            {
                Debug.Assert(bone != null);
                Debug.Assert(skeleton.Contains(bone));

                var childrenWorldPose = bone.GetChildrenWoldPose();

                if (bone.chainedChild != null && ArrayUtility.Contains(bones, bone.chainedChild) == false)
                {
                    bone.chainedChild = null;
                }

                if (bone.parentBone != null && bone.parentBone.chainedChild == bone && ArrayUtility.Contains(bones, bone.parentBone) == false)
                {
                    bone.parentBone.chainedChild = null;
                }

                bone.position += deltaPosition;

                bone.SetChildrenWorldPose(childrenWorldPose);
            }
        }
Ejemplo n.º 8
0
    void ReceivedIssues(List <BugReporterPlugin.IssueEntry> entries)
    {
        _treeView.Reload();

        int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount;

        string[] loadedSceneGUID = new string[sceneCount];
        for (int i = 0; i < sceneCount; ++i)
        {
            var scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i);
            loadedSceneGUID[i] = AssetDatabase.AssetPathToGUID(scene.path);
        }


        _currentOpenEntry = -1;

        _currentLevelsIssues.Clear();
        for (int i = 0; i < entries.Count; ++i)
        {
            if (ArrayUtility.Contains(loadedSceneGUID, entries[i].sceneGUID))
            {
                _currentLevelsIssues.Add(entries[i]);
            }
        }

        SceneView.RepaintAll();
        Repaint();
    }
Ejemplo n.º 9
0
        // Handle Inspector Changes
        private void OnValidate()
        {
            SetupEditorData();
            var obj = gameObject;

            AddAll();

            for (int i = 0; i < _all.Length; i++)
            {
                var tag = _all[i];

                if (ArrayUtility.Contains(_tags, tag))
                {
                    if (!obj.HasTag(tag))
                    {
                        obj.AddTag(tag);
                    }
                }
                else
                {
                    if (obj.HasTag(tag))
                    {
                        obj.RemoveTag(tag);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Helper method to draw enums from a limited range.
        /// </summary>
        /// <typeparam name="ENUM"></typeparam>
        /// <param name="property"></param>
        /// <param name="supportedEnums">List of supported enums.  The first element is treated as default.</param>
        public static void DrawEnum <ENUM>(SerializedProperty property, ENUM[] supportedEnums, ENUM defaultEnum) where ENUM : System.Enum
        {
            // Setup the pop-up
            string[] enumNames  = new string[supportedEnums.Length];
            int[]    enumValues = new int[supportedEnums.Length];
            for (int index = 0; index < supportedEnums.Length; ++index)
            {
                enumNames[index]  = ObjectNames.NicifyVariableName(supportedEnums[index].ToString());
                enumValues[index] = Utility.ConvertToInt(supportedEnums[index]);
            }

            // Disable the pop-up if there's only one option
            bool wasEnabled = GUI.enabled;

            GUI.enabled = (supportedEnums.Length > 1);

            // Show the pop-up
            property.enumValueIndex = EditorGUILayout.IntPopup(property.displayName, property.enumValueIndex, enumNames, enumValues);

            // Revert the later controls
            GUI.enabled = wasEnabled;

            // Verify the selected value is within range
            ENUM selectedValue = Utility.ConvertToEnum <ENUM>(property.enumValueIndex);

            if (ArrayUtility.Contains(supportedEnums, selectedValue) == false)
            {
                // If not, select the default option
                property.enumValueIndex = Utility.ConvertToInt(defaultEnum);
            }
        }
Ejemplo n.º 11
0
    //移除无用的AB
    static void RemoveUnUseAB(string path)
    {
        if (!Directory.Exists(path))
        {
            return;
        }

        string[] curABNameList   = AssetDatabase.GetAllAssetBundleNames();
        string[] unuseABNameList = AssetDatabase.GetUnusedAssetBundleNames();
        for (int i = 0; i < unuseABNameList.Length; i++)
        {
            ArrayUtility.Remove(ref curABNameList, unuseABNameList[i]);
        }
        string[] buildABList = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
        for (int i = 0; i < buildABList.Length; i++)
        {
            string name   = buildABList[i].Replace("\\", "/").Replace(path + "/", "").Split('.')[0];
            bool   isHave = ArrayUtility.Contains(curABNameList, name);
            if (!isHave)
            {
                File.Delete(buildABList[i]);
                //Debug.Log("delete unuse ab : " + name);
            }
        }

        FileUtility.ClearEmptyDirectory(path);
    }
    void SinglePassPreProcess()
    {
        if (target != BuildTarget.Android)
        {
            Debug.LogError("Target platform is not Android");
            return;
        }

        var vrSupported = WaveVR_Settings.GetVirtualRealitySupported(BuildTargetGroup.Android);
        var list        = WaveVR_Settings.GetVirtualRealitySDKs(BuildTargetGroup.Android);
        var hasVRDevice = ArrayUtility.Contains <string>(list, WaveVR_Settings.WVRSinglePassDeviceName);

#if UNITY_2018_2_OR_NEWER
        // Please remove old name
        if (ArrayUtility.Contains <string>(list, "split"))
        {
            Debug.LogError("Contains old VR device name in XR settings.\nPlease remove it.");
        }
#endif
        var           stereoRenderingPath = PlayerSettings.stereoRenderingPath;
        List <string> allDefines          = WaveVR_Settings.GetDefineSymbols(BuildTargetGroup.Android);
        var           hasDefine           = allDefines.Contains(WaveVR_Settings.WVRSPDEF);

        // if single pass enabled in PlayerSettings, set the define.  Here is a final check.
        Debug.Log("SinglePassPreProcess: vrSupported=" + vrSupported + ", stereoRenderingPath=" + stereoRenderingPath +
                  ", hasVRDevice=" + hasVRDevice + ", hasDefine=" + hasDefine);
        var set = vrSupported && hasVRDevice && stereoRenderingPath == StereoRenderingPath.SinglePass;

        WaveVR_Settings.SetSinglePassDefine(group, set, allDefines);
    }
        private void MoonTexturePopup(bool enabledBefore)
        {
            var textures     = _presets.MoonTextures;
            var textureNames = _presets.MoonTextureNames;

            var currentTexture = _moonTexture.objectReferenceValue as Texture2D;

            if (!enabledBefore && textures.Length > 0)
            {
                currentTexture = textures[0];
            }

            var textureIndex = Array.IndexOf(textures, currentTexture);

            if (textureIndex < 0)
            {
                textureIndex = textures.Length;
            }

            textureIndex = EditorGUILayout.Popup("Moon Texture", textureIndex, textureNames);

            if (textureIndex < textures.Length)
            {
                _moonTexture.objectReferenceValue = textures[textureIndex];
            }
            else
            {
                if (ArrayUtility.Contains(textures, currentTexture))
                {
                    _moonTexture.objectReferenceValue = null;
                }
                EditorGUILayout.PropertyField(_moonTexture, _emptyGUIContent);
            }
        }
Ejemplo n.º 14
0
        public override void ShortCut()
        {
            base.ShortCut();
            GameObject active = Selection.activeGameObject;
            var        e      = Event.current;


            if (e.keyCode == KeyCode.C)
            {
                Event.current.Use();

                if (ArrayUtility.Contains(raceSet.raceNodes, active.transform.position))
                {
                    return;
                }

                previousVector3 = active.transform.position;

                ArrayUtility.Add <Vector3>(ref raceSet.raceNodes, active.transform.position);//raceSet.raceNodes

                AidNode.GetComponent <LineRenderer>().positionCount = raceSet.raceNodes.Length;

                AidNode.GetComponent <LineRenderer>().SetPositions(raceSet.raceNodes);
            }
        }
Ejemplo n.º 15
0
    void OnPostprocessGameObjectWithUserProperties(GameObject go, string[] propNames, System.Object[] values)
    {
        int index;

        Debug.Log("Properties: ");
        foreach (string p in propNames)
        {
            //Debug.Log(p);
        }
        if (ArrayUtility.Contains(propNames, "SpatioModel"))
        {
            GenerateSpatioModel(go, propNames, values);
        }
        if ((index = ArrayUtility.FindIndex(propNames, s => s.Equals("UDP3DSMAX"))) >= 0)
        {
            ParseSpatioModel(go, (string)(values[index]));
        }

        /*
         * else if((maxIndex = Array.FindIndex(propNames, s => s.Equals("UDP3DSMAX"))) >= 0)
         * {
         *      System.String propList = (System.String)values [maxIndex];
         *      string[] subProps = propList.Split("&cr;&lf;", System.StringSplitOptions.RemoveEmptyEntries);
         *      string[] props = new string[subProps.Length];
         *      System.Object[] vals = new System.Object[subProps.Length];
         *      Debug.Log (propList + "\n");
         *      Debug.Log (subProps + "\n");
         *
         * for (int i = 0; i < subProps.Length; i++)
         * {
         *              //subProps[i].Substring
         * }
         * }*/
        GenerateSpatioModel(go, propNames, values);
    }
Ejemplo n.º 16
0
        private List <LogData> GetNewLogDataList(LogConfig config)
        {
            List <LogData> datas = new List <LogData>(config.LogDatas);
            Array          enums = Util.GetEnumFields(typeof(LogEnum));

            if (config.LogDatas.Count < Util.GetFieldCount <LogEnum>())
            {
                foreach (LogEnum e in enums)
                {
                    if (datas.Find((i) => i.logEnum.ToString().Equals(e.ToString())) == null)
                    {
                        datas.Add(new LogData()
                        {
                            logEnum  = e,
                            Show     = true,
                            LogColor = Color.white
                        });
                    }
                }
            }
            else
            {
                foreach (var data in config.LogDatas)
                {
                    if (!ArrayUtility.Contains((LogEnum[])enums, data.logEnum))
                    {
                        LogData d = datas.Find((i) => i.logEnum == data.logEnum);
                        datas.Remove(d);
                    }
                }
            }

            return(datas);
        }
Ejemplo n.º 17
0
    void DrawShaderOccurence()
    {
        DrawHeader("Find all materials using this shader", ref shader);

        if (shader != lastShader)
        {
            if (shader == null)
            {
                materials.Clear();
            }
            else
            {
                string   shaderPath   = AssetDatabase.GetAssetPath(shader);
                string[] allMaterials = AssetDatabase.FindAssets("t:Material");
                materials.Clear();
                for (int i = 0; i < allMaterials.Length; i++)
                {
                    allMaterials[i] = AssetDatabase.GUIDToAssetPath(allMaterials[i]);
                    string[] dep = AssetDatabase.GetDependencies(allMaterials[i]);
                    if (ArrayUtility.Contains(dep, shaderPath))
                    {
                        materials.Add(allMaterials[i]);
                    }
                }
            }
            lastShader = shader;
        }

        DrawScrollView(ref scrollMaterials, materials);

        DrawHorizontalLine();
    }
Ejemplo n.º 18
0
        public static void OpenWindow()
        {
            bool hasPlatform = ArrayUtility.Contains(UnityEditorInternal.InternalEditorUtility.tags, "Platform");
            bool hasWater    = ArrayUtility.Contains(UnityEditorInternal.InternalEditorUtility.tags, "Water");
            bool hasLadder   = ArrayUtility.Contains(UnityEditorInternal.InternalEditorUtility.tags, "Ladder");

            if (hasPlatform && hasWater && hasLadder)
            {
                EditorUtility.DisplayDialog("Retro Controller", "All tags are already on the project.", "OK");
                return;
            }

            if (!hasPlatform)
            {
                UnityEditorInternal.InternalEditorUtility.AddTag("Platform");
            }
            if (!hasWater)
            {
                UnityEditorInternal.InternalEditorUtility.AddTag("Water");
            }
            if (!hasLadder)
            {
                UnityEditorInternal.InternalEditorUtility.AddTag("Ladder");
            }

            EditorUtility.DisplayDialog("Retro Controller", "Tags successfully imported!", "OK");
        }
 bool IsGoodToBake(Renderer r, MB2_TextureBakeResults tbr)
 {
     if (r == null)
     {
         return(false);
     }
     if (!(r is MeshRenderer) && !(r is SkinnedMeshRenderer))
     {
         return(false);
     }
     Material[] mats = r.sharedMaterials;
     for (int i = 0; i < mats.Length; i++)
     {
         if (!ArrayUtility.Contains <Material>(tbr.materials, mats[i]))
         {
             Debug.LogWarning("Mesh on " + r + " uses a material " + mats[i] + " that is not in the list of materials. This mesh will not be baked. The original mesh and material will be used in the result prefab.");
             //todo assign the source assets to the result
             return(false);
         }
     }
     if (MB_Utility.GetMesh(r.gameObject) == null)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 20
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (listenStrengthFactor <= 0)
     {
         return;
     }
     foreach (Sound sound in Sound.InstanceList)
     {
         // Calculate the effective sound level, taking into account obstruction and listener strength
         float dist = Vector3.Distance(this.transform.position, sound.transform.position);
         float effectiveSoundLevel = sound.soundLevel * listenStrengthFactor;
         if (dist < effectiveSoundLevel)
         {
             // If possibly in range, fire a ray and dampen if there is an obstruction
             RaycastHit hit;
             Ray        ray = new Ray(this.transform.position, sound.transform.position - this.transform.position);
             if (Physics.Raycast(ray, out hit, dist, layerMask))
             {
                 if (hit.distance - effectiveSoundLevel < 0.1f && !ArrayUtility.Contains(hit.collider.gameObject.GetComponentsInChildren <Sound>(), sound))
                 {
                     effectiveSoundLevel *= Sound.wallDampenFactor;
                 }
             }
         }
         if (dist < effectiveSoundLevel)
         {
             soundMemory.Add(new SoundRecord(sound.soundType, effectiveSoundLevel, sound.transform.position));
         }
     }
 }
        private void CloudsCubemapPopup(bool enabledBefore)
        {
            var cubemaps     = _presets.CloudsCubemaps;
            var cubemapNames = _presets.CloudsCubemapNames;

            var currentCubemap = _cloudsCubemap.objectReferenceValue as Cubemap;

            if (!enabledBefore && cubemaps.Length > 0)
            {
                currentCubemap = cubemaps[0];
            }

            var cubemapIndex = Array.IndexOf(cubemaps, currentCubemap);

            if (cubemapIndex < 0)
            {
                cubemapIndex = cubemaps.Length;
            }

            cubemapIndex = EditorGUILayout.Popup("Clouds Cubemap", cubemapIndex, cubemapNames);

            if (cubemapIndex < cubemaps.Length)
            {
                _cloudsCubemap.objectReferenceValue = cubemaps[cubemapIndex];
            }
            else
            {
                if (ArrayUtility.Contains(cubemaps, currentCubemap))
                {
                    _cloudsCubemap.objectReferenceValue = null;
                }
                EditorGUILayout.PropertyField(_cloudsCubemap, _emptyGUIContent);
            }
        }
        public override void OnInspectorGUI()
        {
            if (hasCustomInspector)
            {
                inspectorGUIMethod.Invoke(container, null);
            }
            else
            {
                DrawDefaultInspector();
            }

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Runtime Value");

            if (container.UntypedValue == null)
            {
                EditorGUILayout.SelectableLabel("null");
            }
            else
            {
                EditorGUILayout.SelectableLabel(container.UntypedValue.ToString());
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Force Value Update Event"))
            {
                container.ForceUpdate();
            }

            if (GUILayout.Button("Saving & Loading"))
            {
                GenericMenu menu = new GenericMenu();
                List <SaveConfiguration> configurations = SavePortEditorUtils.FindAllAssetsOfType <SaveConfiguration>();

                if (configurations.Count == 0)
                {
                    EditorUtility.DisplayDialog("SavePort", "No SavePort configuration files were found in this project. Please create one to proceed.", "OK");
                    return;
                }

                menu.AddDisabledItem(new GUIContent("Select configuration"));

                foreach (SaveConfiguration config in configurations)
                {
                    bool isSaved = ArrayUtility.Contains(config.GetContainerEntries().Select(x => x.container).ToArray(), container);
                    menu.AddItem(new GUIContent(config.name), isSaved, () => ProcessConfigMenu(container, config, isSaved));
                }

                menu.ShowAsContext();
            }

            GUILayout.EndHorizontal();
        }
Ejemplo n.º 23
0
        void OnGUI()
        {
            GUILayout.Label("Select a shader");
            Shader prev = shader;

            shader = EditorGUILayout.ObjectField(shader, typeof(Shader), false) as Shader;
            GUILayout.Label("Type out keyword, case sensitive");

            shaderKeyword = EditorGUILayout.TextField("Shader Keyword to enable : ", shaderKeyword);

            if (shader != prev)
            {
                string   shaderPath   = AssetDatabase.GetAssetPath(shader);
                string[] allMaterials = AssetDatabase.FindAssets("t:Material");
                materials.Clear();
                for (int i = 0; i < allMaterials.Length; i++)
                {
                    allMaterials[i] = AssetDatabase.GUIDToAssetPath(allMaterials[i]);
                    string[] dep = AssetDatabase.GetDependencies(allMaterials[i]);
                    if (ArrayUtility.Contains(dep, shaderPath))
                    {
                        materials.Add(allMaterials[i]);
                    }
                }
            }

            scroll = GUILayout.BeginScrollView(scroll);
            {
                for (int i = 0; i < materials.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(Path.GetFileNameWithoutExtension(materials[i]));
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Show"))
                        {
                            EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(materials[i], typeof(Material)));
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();

            if (GUILayout.Button("Enable keyword"))
            {
                for (int i = 0; i < materials.Count; i++)
                {
                    Material mat = AssetDatabase.LoadAssetAtPath(materials[i], typeof(Material)) as Material;
                    //mat.EnableKeyword(keywordsToAdd[i]);
                    if (mat != null && !mat.IsKeywordEnabled(shaderKeyword))
                    {
                        mat.EnableKeyword(shaderKeyword);
                    }
                }
            }
        }
Ejemplo n.º 24
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6);
        float controlSize = 64;

        EditorGUIUtility.LookLikeControls(Screen.width - controlSize - 20);

        targetMat = target as Material;
        string[] keyWords = targetMat.shaderKeywords;
        SetTexture("_RampTex", TextureProperty("_RampTex", "Color Ramp", ShaderUtil.ShaderPropertyTexDim.TexDim2D));
        SetFloat("_Radius", FloatProperty("_Radius", "Radius"));
        SetFloat("_Heat", FloatProperty("_Heat", "Heat"));
        //bool octaves = ArrayUtility.Contains(keyWords, "OCTAVES_1");

        //checkbox for scattering
        scattering = !ArrayUtility.Contains(keyWords, "SCATTERING_OFF");
        scattering = EditorGUILayout.Toggle("Scattering", scattering);
        if (scattering != prevscatter)
        {
            changed     = true;
            prevscatter = scattering;
        }

        //handle noise octave count
        octaves = EditorGUILayout.Popup("Octaves", OctavesValue() - 1, new[] { "1", "2", "3", "4", "5" }) + 1;    //the +/- 1 is transferring array index to actual number
        if (octaves != prevoctaves)
        {
            changed     = true;
            prevoctaves = octaves;
        }

        //handle quality
        quality = EditorGUILayout.Popup("Quality", Quality(), new[] { "Low", "Medium", "High" });
        if (quality != prevquality)
        {
            changed     = true;
            prevquality = quality;
        }

        advanced = EditorGUILayout.Foldout(advanced, "Advanced");
        if (advanced)
        {
            EditorGUILayout.LabelField("Noise Texture:");
            SetTexture("_MainTex", TextureProperty("_MainTex", "Check the readme for requirements", ShaderUtil.ShaderPropertyTexDim.TexDim2D));
            SetVector("_SpherePos", VectorProperty("_SpherePos", "Sphere Position"));
        }

        if (changed)
        {
            var newKeywords = new List <string> {
                scattering ? "SCATTERING_ON" : "SCATTERING_OFF", "OCTAVES_" + octaves, qualitySel[quality]
            };
            targetMat.shaderKeywords = newKeywords.ToArray();
            EditorUtility.SetDirty(targetMat);
        }
    }
Ejemplo n.º 25
0
    private bool GetBeaconPropertyAttributeResult(BeaconPropertyAttribute beaconAttribute, SerializedProperty property, out BeaconType type)
    {
        var sb = new StringBuilder(property.propertyPath);
        var i  = property.propertyPath.LastIndexOf('.') + 1;

        sb.Remove(i, property.propertyPath.Length - i);
        sb.Append("_type");
        type = (BeaconType)property.serializedObject.FindProperty(sb.ToString()).enumValueIndex;
        return(ArrayUtility.Contains <BeaconType>(beaconAttribute.Types, type) ^ beaconAttribute.Exclude);
    }
Ejemplo n.º 26
0
    private bool DrawWarningString(SerializedProperty texture)
    {
        //normal map warning
        if (DisplayModes == null)
        {
            return(false);
        }

        if (ArrayUtility.Contains(DisplayModes, TextureVisualizeMode.NRM))
        {
            if (texture.hasMultipleDifferentValues || texture.objectReferenceValue == null)
            {
                return(false);
            }

            string path = AssetDatabase.GetAssetPath(texture.objectReferenceValue);

            if (!string.IsNullOrEmpty(path))
            {
                var imp      = AssetImporter.GetAtPath(path);
                var importer = imp as TextureImporter;

                if (importer != null && !importer.normalmap)
                {
                    //return "Texture not marked as normal map";

                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("Texture not marked as normal map", MessageType.Warning, true);

                    var rect = GUILayoutUtility.GetLastRect();

                    rect.xMin += rect.width / 2;

                    GUILayout.BeginVertical();

                    GUILayout.Space(14.0f);

                    if (GUILayout.Button("Fix now", EditorStyles.toolbarButton, GUILayout.Width(60.0f)))
                    {
                        importer.textureType = TextureImporterType.Bump;
                        importer.normalmap   = true;
                        AssetDatabase.ImportAsset(path);
                    }

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();

                    return(true);
                }
            }
        }

        return(false);
    }
Ejemplo n.º 27
0
        public void PopulateSDFFontAsset()
        {
            // Char still have to follow what parsed Catalog says.
            var     availableChars = TMP_FontAsset.GetCharactersArray(SDF_Asset);
            var     newChars       = new TexChar[parsedCatalogs.Length == 0 ? availableChars.Length : parsedCatalogs.Length];
            var     info           = SDF_Asset.fontInfo;
            var     padding        = info.Padding;
            TexChar ch;

            chars = chars ?? new TexChar[0];
            for (int i = 0; i < newChars.Length; i++)
            {
                if (parsedCatalogs.Length == 0)
                {
                    ch = newChars[i] = chars.FirstOrDefault(j => j.characterIndex == availableChars[i]) ?? new TexChar(this, i, parsedCatalogs[i], true, 1);
                }
                else
                {
                    ch = newChars[i] = chars.FirstOrDefault(j => j.characterIndex == parsedCatalogs[i]) ?? new TexChar(this, i, parsedCatalogs[i], true, 1);
                }

                if (!(ch.supported = parsedCatalogs.Length == 0 || ArrayUtility.Contains(availableChars, parsedCatalogs[i])))
                {
                    continue;
                }

                TMP_Glyph c = SDF_Asset.characterDictionary[parsedCatalogs[i]];

                var factor = c.scale / info.PointSize;

                ch.depth   = (c.height - c.yOffset + padding) * factor;
                ch.height  = (c.yOffset + padding) * factor;
                ch.bearing = (-c.xOffset + padding) * factor;
                ch.italic  = (c.width + c.xOffset + padding) * factor;
                ch.width   = c.xAdvance * factor;

                var uv = new Rect();
                uv.x      = (c.x - padding) / info.AtlasWidth;
                uv.y      = 1 - (c.y + c.height + padding) / info.AtlasHeight;
                uv.width  = (c.width + 2 * padding) / info.AtlasWidth;
                uv.height = (c.height + 2 * padding) / info.AtlasHeight;

                //var uv = new Rect(c.x / info.AtlasWidth, c.y / info.AtlasHeight,
                //    c.width / info.AtlasWidth, c.height / info.AtlasHeight);
                ch.sprite_uv = uv;
                ch.fontIndex = index;
                ch.index     = i;
            }
            chars            = newChars;
            font_lineHeight  = Mathf.Max(0.2f, info.LineHeight / info.PointSize);
            sprite_xLength   = 8;
            sprite_yLength   = chars.Length / 8 + 1;
            sprite_alphaOnly = true;
            Sprite_Asset     = SDF_Asset.atlas;
        }
Ejemplo n.º 28
0
    public override void OnEnable()
    {
        base.OnEnable();

        Material targetMat = target as Material;

        string[] keywordsCurrent = targetMat.shaderKeywords;

        // ---- FRONT ----
        bool frontSolidOn    = ArrayUtility.Contains(keywordsCurrent, FRONT_SOLID_ON);
        bool frontGradientOn = ArrayUtility.Contains(keywordsCurrent, FRONT_GRADIENT_ON);

        showFront = new AnimBool(frontSolidOn || frontGradientOn);
        showFront.valueChanged.AddListener(Repaint);
        frontMode = frontGradientOn ? ColorMode.GRADIENT : (frontSolidOn ? ColorMode.SOLID : ColorMode.OFF);

        // ---- BACK ----
        bool backSolidOn    = ArrayUtility.Contains(keywordsCurrent, BACK_SOLID_ON);
        bool backGradientOn = ArrayUtility.Contains(keywordsCurrent, BACK_GRADIENT_ON);

        showBack = new AnimBool(backSolidOn || backGradientOn);
        showBack.valueChanged.AddListener(Repaint);
        backMode = backGradientOn ? ColorMode.GRADIENT : (backSolidOn ? ColorMode.SOLID : ColorMode.OFF);

        // ---- LEFT ----
        bool leftSolidOn    = ArrayUtility.Contains(keywordsCurrent, LEFT_SOLID_ON);
        bool leftGradientOn = ArrayUtility.Contains(keywordsCurrent, LEFT_GRADIENT_ON);

        showLeft = new AnimBool(leftSolidOn || leftGradientOn);
        showLeft.valueChanged.AddListener(Repaint);
        leftMode = leftGradientOn ? ColorMode.GRADIENT : (leftSolidOn ? ColorMode.SOLID : ColorMode.OFF);

        // ---- RIGHT ----
        bool rightSolidOn    = ArrayUtility.Contains(keywordsCurrent, RIGHT_SOLID_ON);
        bool rightGradientOn = ArrayUtility.Contains(keywordsCurrent, RIGHT_GRADIENT_ON);

        showRight = new AnimBool(rightSolidOn || rightGradientOn);
        showRight.valueChanged.AddListener(Repaint);
        rightMode = rightGradientOn ? ColorMode.GRADIENT : (rightSolidOn ? ColorMode.SOLID : ColorMode.OFF);

        lightmapOn = ArrayUtility.Contains(keywordsCurrent, LIGHTMAP_COLR_ON);

        independentSides = ArrayUtility.Contains(keywordsCurrent, INDEPENDENT_SIDES);
        fogBottom        = ArrayUtility.Contains(keywordsCurrent, FOG_BOTTOM);

        // If old version of Colr and local space, replace shader.
        if (!ArrayUtility.Contains(targetMat.shaderKeywords, "COLR_1_2") &&
            !ArrayUtility.Contains(targetMat.shaderKeywords, "WORLD_SPACE_ON"))
        {
            targetMat.shader = Shader.Find("Colr/Master Shader Local Space");
            Repaint();
        }

        ApplyProperties();
    }
Ejemplo n.º 29
0
        public static HideFlagsState BeginPicking(GameObject[] ignoreGameObjects)
        {
            var state = new HideFlagsState()
            {
                generatedComponents = new Dictionary <UnityEngine.GameObject, CSGModel>(),
                hideFlags           = new Dictionary <UnityEngine.GameObject, HideFlags>()
            };

            foreach (var model in CSGModelManager.GetAllModels())
            {
                if (!model.generatedMeshes)
                {
                    continue;
                }

                var renderers = model.generatedMeshes.GetComponentsInChildren <Renderer>();
                if (renderers != null)
                {
                    foreach (var renderer in renderers)
                    {
                        state.generatedComponents[renderer.gameObject] = model;
                    }
                }

                var colliders = model.generatedMeshes.GetComponentsInChildren <Collider>();
                if (colliders != null)
                {
                    foreach (var collider in colliders)
                    {
                        state.generatedComponents[collider.gameObject] = model;
                    }
                }
            }
            if (state.generatedComponents != null)
            {
                foreach (var pair in state.generatedComponents)
                {
                    var gameObject = pair.Key;
                    var model      = pair.Value;

                    state.hideFlags[gameObject] = gameObject.hideFlags;

                    if (ignoreGameObjects != null &&
                        ArrayUtility.Contains(ignoreGameObjects, model.gameObject))
                    {
                        gameObject.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy;
                    }
                    else
                    {
                        gameObject.hideFlags = HideFlags.None;
                    }
                }
            }
            return(state);
        }
Ejemplo n.º 30
0
        public void Refresh()
        {
            isInstalled = !namespaceclass.IsNullOrEmpty()? NamespaceUtility.IsNamespaceExists(namespaceclass) : true;

            if (!isInstalled)
            {
                isInstalled = !namespaceclass.IsNullOrEmpty()? TypeUtility.IsTypeExist(namespaceclass) : true;
            }

            isPlatformSupported = platforms.IsNullOrEmpty()? true : ArrayUtility.Contains(platforms, EditorUserBuildSettings.activeBuildTarget);
        }