private static void Write(UnsafeWriter writer, InspectorVariableUsage value)
 {
     value.Location.WriteTo(writer);
     value.ScriptReference.WriteTo(writer);
     writer.Write(value.Name);
     writer.WritePolymorphic(value.Value);
 }
        private void AddChangesPerFile(MonoBehaviourField monoBehaviourField, InspectorVariableUsage variableUsage)
        {
            var beforeAddDifferentValuesCount = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).Count;

            if (beforeAddDifferentValuesCount == 0)
            {
                myValueCountPerPropertyAndFile.Add(monoBehaviourField, variableUsage.Value.GetHashCode());

                var fieldWithValue = new MonoBehaviourFieldWithValue(new MonoBehaviourField(monoBehaviourField.ScriptGuid, monoBehaviourField.NameHash), variableUsage.Value.GetHashCode());
                myValuesWhichAreUniqueInWholeFile.Add(fieldWithValue);
            }
            else if (beforeAddDifferentValuesCount == 1)
            {
                var previousValue = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).First().Key;
                myValueCountPerPropertyAndFile.Add(monoBehaviourField, variableUsage.Value.GetHashCode());
                var afterAddDifferentValuesCount = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).Count;

                if (afterAddDifferentValuesCount == 2)
                {
                    var fieldWithValue = new MonoBehaviourFieldWithValue(new MonoBehaviourField(monoBehaviourField.ScriptGuid, monoBehaviourField.NameHash), previousValue);
                    myValuesWhichAreUniqueInWholeFile.Remove(fieldWithValue);
                }
            }
            else
            {
                myValueCountPerPropertyAndFile.Add(monoBehaviourField, variableUsage.Value.GetHashCode());
            }
        }
예제 #3
0
        private void AddUniqueValue(MonoBehaviourField field, InspectorVariableUsage variableUsage)
        {
            if (!myUniqueValues.TryGetValue(field, out var oneToCompactCountingSet))
            {
                oneToCompactCountingSet = new OneToCompactCountingSet <IAssetValue, InspectorVariableUsage>();
                myUniqueValues[field]   = oneToCompactCountingSet;
            }

            oneToCompactCountingSet.Add(variableUsage.Value, variableUsage);
        }
        private void AddUniqueValue(MonoBehaviourField field, InspectorVariableUsage variableUsage)
        {
            var uniqueValuePtr = variableUsage.Value.GetHashCode();

            var previousCount = myUniqueValuesCount.GetOrEmpty(field).Count;

            myUniqueValuesCount.Add(field, uniqueValuePtr);
            var newCount = myUniqueValuesCount.GetOrEmpty(field).Count;

            if (previousCount < 2 && newCount != previousCount)
            {
                var isAdded = myUniqueValuesInstances.Add(field, variableUsage.Value);
                Assertion.Assert(isAdded, "value should not be presented");
            }
        }
        private void RemoveUniqueValue(MonoBehaviourField mbField, InspectorVariableUsage variableUsage)
        {
            var valueHash = variableUsage.Value.GetHashCode();

            var previousCount = myUniqueValuesCount.GetOrEmpty(mbField).Count;

            myUniqueValuesCount.Remove(mbField, valueHash);
            var newCount = myUniqueValuesCount.GetOrEmpty(mbField).Count;

            if (newCount < 2 && newCount != previousCount)
            {
                var isRemoved = myUniqueValuesInstances.Remove(mbField, variableUsage.Value);
                Assertion.Assert(isRemoved, "value should be presented");
            }
        }
예제 #6
0
 private void RemoveUniqueValue(MonoBehaviourField mbField, InspectorVariableUsage variableUsage)
 {
     if (!myUniqueValues.TryGetValue(mbField, out var oneToCompactCountingSet))
     {
         Assertion.Fail("mbField is not presented");
     }
     else
     {
         oneToCompactCountingSet.Remove(variableUsage.Value, variableUsage);
         if (oneToCompactCountingSet.Count == 0)
         {
             myUniqueValues.Remove(mbField);
         }
     }
 }
예제 #7
0
        private void RemoveChangesPerFile(MonoBehaviourField monoBehaviourField, InspectorVariableUsage variableUsage)
        {
            var beforeRemoveDifferentValuesCount = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).Count;

            myValueCountPerPropertyAndFile.Remove(monoBehaviourField, variableUsage.Value);
            var afterRemoveDifferentValuesCount = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).Count;

            if (beforeRemoveDifferentValuesCount == 2 && afterRemoveDifferentValuesCount == 1)
            {
                var uniqueValue    = myValueCountPerPropertyAndFile.GetOrEmpty(monoBehaviourField).First().Key;
                var fieldWithValue = new MonoBehaviourFieldWithValue(new MonoBehaviourField(monoBehaviourField.ScriptGuid, monoBehaviourField.Name), uniqueValue);
                myValuesWhichAreUniqueInWholeFile.Add(fieldWithValue);
            }
            else if (beforeRemoveDifferentValuesCount == 1 && afterRemoveDifferentValuesCount == 0)
            {
                var fieldWithValue = new MonoBehaviourFieldWithValue(new MonoBehaviourField(monoBehaviourField.ScriptGuid, monoBehaviourField.Name), variableUsage.Value);
                myValuesWhichAreUniqueInWholeFile.Remove(fieldWithValue);
            }
        }
 protected bool Equals(InspectorVariableUsage other)
 {
     return(Location.Equals(other.Location) && ScriptReference.Equals(other.ScriptReference) && Name == other.Name && Value.Equals(other.Value));
 }