예제 #1
0
        public static Material EditorCreateOrLoadMaskMaterialAsset(SkeletonRenderer.SpriteMaskInteractionMaterials maskMaterials,
                                                                   UnityEngine.Rendering.CompareFunction maskFunction, Material originalMaterial)
        {
            string originalMaterialPath = UnityEditor.AssetDatabase.GetAssetPath(originalMaterial);
            int    posOfExtensionDot    = originalMaterialPath.LastIndexOf('.');
            string materialPath         = (maskFunction == SkeletonRenderer.STENCIL_COMP_MASKINTERACTION_VISIBLE_INSIDE) ?
                                          originalMaterialPath.Insert(posOfExtensionDot, MATERIAL_FILENAME_SUFFIX_INSIDE_MASK) :
                                          originalMaterialPath.Insert(posOfExtensionDot, MATERIAL_FILENAME_SUFFIX_OUTSIDE_MASK);

            Material material = UnityEditor.AssetDatabase.LoadAssetAtPath <Material>(materialPath);

            if (material != null)
            {
                return(material);
            }

            material = new Material(originalMaterial);
            material.SetFloat(SkeletonRenderer.STENCIL_COMP_PARAM_ID, (int)maskFunction);

            UnityEditor.AssetDatabase.CreateAsset(material, materialPath);
            Debug.Log(string.Concat("Created material '", materialPath, "' for mask interaction based on '", originalMaterialPath, "'."));
            UnityEditor.EditorUtility.SetDirty(material);
            UnityEditor.AssetDatabase.SaveAssets();
            return(material);
        }
    private void ZTest(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle, string inspector, string flag)
    {
        MaterialProperty zTestM = ShaderGUI.FindProperty("_ZTestMode", properties);

        if (zTestM.floatValue == 0)
        {
            zTestM.floatValue = 4;
        }
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup(inspector, toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(flag);
            EditorGUILayout.BeginVertical(style);
            {
                GUILayout.Label("Look for 'ShaderLab culling and depth testing' if you don't know what this is", style);
                zTestMode         = (UnityEngine.Rendering.CompareFunction)zTestM.floatValue;
                zTestMode         = (UnityEngine.Rendering.CompareFunction)EditorGUILayout.EnumPopup("zTestMode", zTestMode);
                zTestM.floatValue = (float)(zTestMode);
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(flag);
        }
        EditorGUILayout.EndToggleGroup();
    }
        private static void ApplyWireMaterial(UnityEngine.Rendering.CompareFunction zTest)
        {
            Material mat = handleWireMaterial;

            mat.SetInt("_HandleZTest", (int)zTest);
            mat.SetPass(0);
        }
        static StackObject *Add_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 7);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 writeMask = ptr_of_this_method->Value;
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Int32 readMask = ptr_of_this_method->Value;
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            UnityEngine.Rendering.ColorWriteMask colorWriteMask = (UnityEngine.Rendering.ColorWriteMask) typeof(UnityEngine.Rendering.ColorWriteMask).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            UnityEngine.Rendering.CompareFunction compareFunction = (UnityEngine.Rendering.CompareFunction) typeof(UnityEngine.Rendering.CompareFunction).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 5);
            UnityEngine.Rendering.StencilOp operation = (UnityEngine.Rendering.StencilOp) typeof(UnityEngine.Rendering.StencilOp).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 6);
            System.Int32 stencilID = ptr_of_this_method->Value;
            ptr_of_this_method = ILIntepreter.Minus(__esp, 7);
            UnityEngine.Material baseMat = (UnityEngine.Material) typeof(UnityEngine.Material).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = UnityEngine.UI.StencilMaterial.Add(baseMat, stencilID, operation, compareFunction, colorWriteMask, readMask, writeMask);

            object obj_result_of_this_method = result_of_this_method;

            if (obj_result_of_this_method is CrossBindingAdaptorType)
            {
                return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance));
            }
            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
        internal static void ApplyDottedWireMaterial([uei.DefaultValue("UnityEngine.Rendering.CompareFunction.Always")] UnityEngine.Rendering.CompareFunction zTest)
        {
            Material mat = handleDottedWireMaterial;

            mat.SetInt("_HandleZTest", (int)zTest);
            mat.SetPass(0);
            int textureIndex = Camera.current ? s_HandleDottedWireTextureIndex : s_HandleDottedWireTextureIndex2D;

            Internal_SetHandleWireTextureIndex(textureIndex);
        }
예제 #6
0
        public static void DrawSplineGizmos(ObiCurve curve, int resolution, Color color, Color culledColor, Color orientationColor, bool drawOrientation = true)
        {
            if (curve == null || curve.GetNumSpans() == 0)
            {
                return;
            }

            Matrix4x4 prevMatrix = Handles.matrix;

            UnityEngine.Rendering.CompareFunction oldZTest = Handles.zTest;
            Color oldColor = Handles.color;

            Handles.matrix = curve.transform.localToWorldMatrix;
            Handles.color  = orientationColor;

            // Draw the curve:
            int curveSegments = curve.GetNumSpans() * resolution;

            Vector3[] samples = new Vector3[curveSegments + 1];

            for (int i = 0; i <= curveSegments; ++i)
            {
                float mu = i / (float)curveSegments;
                samples[i] = curve.GetPositionAt(mu);

                if (drawOrientation)
                {
                    Vector3 right     = Vector3.Cross(curve.GetFirstDerivativeAt(mu), curve.GetNormalAt(mu)).normalized;
                    Vector3 direction = Vector3.Cross(right, curve.GetFirstDerivativeAt(mu)).normalized;
                    Handles.DrawLine(samples[i], samples[i] + direction * 0.075f);
                }
            }

            Handles.color = color;
            Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;
            Handles.DrawPolyLine(samples);

            Handles.color = culledColor;
            Handles.zTest = UnityEngine.Rendering.CompareFunction.Greater;
            Handles.DrawPolyLine(samples);

            Handles.color  = oldColor;
            Handles.matrix = prevMatrix;
            Handles.zTest  = oldZTest;
        }
예제 #7
0
        private bool InitSpriteMaskMaterialsForMaskType(UnityEngine.Rendering.CompareFunction maskFunction, ref Material[] materialsToFill)
        {
                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return(false);
            }
                        #endif

            var originalMaterials = maskMaterials.materialsMaskDisabled;
            materialsToFill = new Material[originalMaterials.Length];
            for (int i = 0; i < originalMaterials.Length; i++)
            {
                Material newMaterial = new Material(originalMaterials[i]);
                newMaterial.SetFloat(STENCIL_COMP_PARAM_ID, (int)maskFunction);
                materialsToFill[i] = newMaterial;
            }
            return(true);
        }
예제 #8
0
    private void StencilSettings(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        EditorGUILayout.Separator();
        GUILayout.Label("Stencil Settings", bigLabel);
        materialEditor.ShaderProperty(properties[149], properties[149].displayName);

        MaterialProperty stencilOpMP = ShaderGUI.FindProperty("_StencilOp", properties);

        UnityEngine.Rendering.StencilOp stencilOp = (UnityEngine.Rendering.StencilOp)stencilOpMP.floatValue;
        stencilOp = (UnityEngine.Rendering.StencilOp)stencilOpMP.floatValue;
        stencilOp = (UnityEngine.Rendering.StencilOp)EditorGUILayout.EnumPopup("StencilOp", stencilOp);
        stencilOpMP.floatValue = (float)(stencilOp);

        MaterialProperty stencilCompMP = ShaderGUI.FindProperty("_StencilComp", properties);

        stencilComp = (UnityEngine.Rendering.CompareFunction)stencilCompMP.floatValue;
        stencilComp = (UnityEngine.Rendering.CompareFunction)EditorGUILayout.EnumPopup("StencilComp", stencilComp);
        stencilCompMP.floatValue = (float)(stencilComp);
    }
예제 #9
0
        private static void EditorInitSpriteMaskMaterialsForMaskType(SkeletonRenderer skeleton, UnityEngine.Rendering.CompareFunction maskFunction,
                                                                     ref Material[] materialsToFill)
        {
            if (!EditorConfirmDisabledMaskMaterialsInit(skeleton))
            {
                return;
            }

            var maskMaterials     = skeleton.maskMaterials;
            var originalMaterials = maskMaterials.materialsMaskDisabled;

            materialsToFill = new Material[originalMaterials.Length];
            for (int i = 0; i < originalMaterials.Length; i++)
            {
                Material newMaterial = null;

                if (!Application.isPlaying)
                {
                    newMaterial = EditorCreateOrLoadMaskMaterialAsset(maskMaterials, maskFunction, originalMaterials[i]);
                }
                if (newMaterial == null)
                {
                    newMaterial = new Material(originalMaterials[i]);
                    newMaterial.SetFloat(SkeletonRenderer.STENCIL_COMP_PARAM_ID, (int)maskFunction);
                }
                materialsToFill[i] = newMaterial;
            }
        }
 private static void ApplyWireMaterial()
 {
     UnityEngine.Rendering.CompareFunction zTest = UnityEngine.Rendering.CompareFunction.Always;
     ApplyWireMaterial(zTest);
 }
예제 #11
0
 public DepthState(bool writeEnabled, UnityEngine.Rendering.CompareFunction compareFunction = UnityEngine.Rendering.CompareFunction.LessEqual)
 {
     this.m_WriteEnabled    = Convert.ToByte(writeEnabled);
     this.m_CompareFunction = (sbyte)compareFunction;
 }
 internal static void ApplyDottedWireMaterial()
 {
     UnityEngine.Rendering.CompareFunction zTest = UnityEngine.Rendering.CompareFunction.Always;
     ApplyDottedWireMaterial(zTest);
 }